Company: HSBC_29aug
Difficulty: medium
Secret Catacomb Problem Description Alex is an archaeologist. While exploring a catacomb, he finds a sequence of n integers a[1], a[2], ..., a[n] written on a wall. Another wall, once translated, reads "Minimum Operations?" and describes a single operation that Alex may repeat as many times as he likes: Take the number currently at the k -th position of the sequence (positions are 1-indexed and counted from the front of the sequence as it is right now) and append a copy of it to the end of the sequence. Remove the first number of the sequence. After every operation the sequence again has exactly n numbers. Find the minimum number of operations needed to make all n numbers in the sequence identical. If no number of operations can ever do that, the answer is -1 . Complete the function solve(n, k, a) , which returns the minimum number of operations, or -1 if it is impossible. Input Format The first line contains two space-separated integers n and k . The second line contains n space-separ