<p>You are given an integer array <code>nums</code>, an integer array <code>queries</code>, and an integer <code>x</code>.</p>

<p>For each <code>queries[i]</code>, you need to find the index of the <code>queries[i]<sup>th</sup></code> occurrence of <code>x</code> in the <code>nums</code> array. If there are fewer than <code>queries[i]</code> occurrences of <code>x</code>, the answer should be -1 for that query.</p>

<p>Return an integer array <code>answer</code> containing the answers to all queries.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [1,3,1,7], queries = [1,3,2,4], x = 1</span></p>

<p><strong>Output:</strong> <span class="example-io">[0,-1,2,-1]</span></p>

<p><strong>Explanation:</strong></p>

<ul>
	<li>For the 1<sup>st</sup> query, the first occurrence of 1 is at index 0.</li>
	<li>For the 2<sup>nd</sup> query, there are only two occurrences of 1 in <code>nums</code>, so the answer is -1.</li>
	<li>For the 3<sup>rd</sup> query, the second occurrence of 1 is at index 2.</li>
	<li>For the 4<sup>th</sup> query, there are only two occurrences of 1 in <code>nums</code>, so the answer is -1.</li>
</ul>
</div>

<p><strong class="example">Example 2:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [1,2,3], queries = [10], x = 5</span></p>

<p><strong>Output:</strong> <span class="example-io">[-1]</span></p>

<p><strong>Explanation:</strong></p>

<ul>
	<li>For the 1<sup>st</sup> query, 5 doesn&#39;t exist in <code>nums</code>, so the answer is -1.</li>
</ul>
</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= nums.length, queries.length &lt;= 10<sup>5</sup></code></li>
	<li><code>1 &lt;= queries[i] &lt;= 10<sup>5</sup></code></li>
	<li><code>1 &lt;= nums[i], x &lt;= 10<sup>4</sup></code></li>
</ul>

from typing import List

class Solution:
    def occurrencesOfElement(self, nums: List[int], queries: List[int], x: int) -> List[int]:
        # Step 1: Preprocess and find all indices of x in nums
        indices_of_x = [i for i, num in enumerate(nums) if num == x]
        
        # Step 2: Answer each query
        answer = []
        for q in queries:
            # Check if the q-th occurrence of x exists
            if q <= len(indices_of_x):
                answer.append(indices_of_x[q - 1])
            else:
                answer.append(-1)
        
        return answer

# Example usage:
# sol = Solution()
# print(sol.occurrencesOfElement([1, 3, 1, 7], [1, 3, 2, 4], 1))  # Output: [0, -1, 2, -1]
# print(sol.occurrencesOfElement([1, 2, 3], [10], 5))  # Output: [-1]
34900