Company: HSBC_29aug
Difficulty: medium
Secret Catacomb Problem Description Alex is an archaeologist, and one day while exploring a catacomb, he discovered a sequence of n symbols representing n-integers written on the wall. On another wall, when translated, were the words "Minimum Operations" and some instructions he needed to follow. According to the instructions, Alex can perform the following two steps in a single operation: Select the number that is currently in the k-th position of the sequence and append this number to the end of the sequence. Remove the first number of the sequence. The instructions tell Alex to determine the minimum number of operations needed to make all numbers in the sequence identical. Alex is not good with puzzles, so he sent you the sequence and instructions. If it is impossible to make all numbers the same, print -1. Input Format The input consists of two lines: The first line contains the two space separated integers n and k . The second line contains n space-separated integers: a1, a2, ...,