Tap here to switch tabs
Problem
Submissions

Problem: Find Occurrences of an Element in an Array

Find Occurrences of an Element in an Array asks you to return the position in the input array of each requested occurrence of a target value, or minus one when it does not exist.

Statement

You are given an integer array nums, an integer array queries, and an integer x.

For each query queries[i], find the index of the queries[i]th occurrence of x in nums. If x occurs fewer than queries[i] times in nums, the answer for that query is −1-1.

Return an array containing the results for all queries in the given order.

Constraints:

  • 1≤1 \leq nums.length, queries.length ≤105\leq 10^5

  • 1≤1 \leq queries[i] ≤105\leq 10^5

  • 1≤1 \leq nums[i], x ≤104\leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Occurrences of an Element in an Array

Find Occurrences of an Element in an Array asks you to return the position in the input array of each requested occurrence of a target value, or minus one when it does not exist.

Statement

You are given an integer array nums, an integer array queries, and an integer x.

For each query queries[i], find the index of the queries[i]th occurrence of x in nums. If x occurs fewer than queries[i] times in nums, the answer for that query is −1-1.

Return an array containing the results for all queries in the given order.

Constraints:

  • 1≤1 \leq nums.length, queries.length ≤105\leq 10^5

  • 1≤1 \leq queries[i] ≤105\leq 10^5

  • 1≤1 \leq nums[i], x ≤104\leq 10^4