Poshmark | 07 Jan, 2026 | Nth Occurrence Query | Technical Round 2
Question · Posted Mar 2026
Question: Nth Occurrence Query Description You are given an array arr, a value X, and an array of queries queryValues. For each query q in queryValues, determine: The 1-based position of the q^th occurrence of X in arr If X appears fewer than q times, return -1 Return an array of answers, one for each query. Example Suppose arr = [1, 2, 20, 8, 8], X = 8, and queryValues = [100, 4, 2]. Output: [-1, -1, 5] Explanation: There ...
The full answer & interview discussion are available to premium members.
Log in Create a free account