IBM Campus Placement | kth Occurrence in Array | Complete Solutions & Tips

IBM · Question · Posted Apr 2026

Problem Statement: There is an array of integers, arr, and an integer value X. For each element in another array of integers, query_values, return the 1-based index in arr of the query_values[i] occurrence of X. If X does not occur query_values[i] times, return -1 for that query. Example arr = [1, 2, 20, 8, 8, 1, 2, 5, 8, 0] X = 8 query_values = [100, 4, 2] There is no 100th or 4th instance of X = 8 in ...

The full answer & interview discussion are available to premium members.

Log in Create a free account