Input: n = 3, m = 3, k = 3
Output: 3
Array after each steps:
Operation 1: arr[] = {3, 4, 3}
Operation 2: arr[] = {3, 4, 3, 5, 3, 4, 3}
Operation 3: arr[] = {3, 4, 3, 5, 3, 4, 3, 6, 3, 4, 3, 5, 3, 4, 3}
Input: n = 9, m = 74, k = 100
Output: 76
From the above analysis after applying the reverse approach there is a conclusion that element at position k depends upon binary representation of k and i.e. The element at position is equal to (m-1) + position of right most set bit in k.