题目描述
You are given an array nums of size n and q queries. Now for each query of the form l, r and k, output the kth smallest number in sub-array between l and r.
Example 1:
Input: nums = {4, 1, 2, 2, 3},
Query = {{1, 5, 2}, {3, 5, 3}}
Output: {2, 3}
Explanation: For the 1st query 2nd smallest in
[1, 5] is 2. For the 2nd query 3rd smallest in
[3, 5] is 3.
Example 2:
Input: nums = {1, 2, 3, 4, 5},
Query = {{2, 5, 1}}
Output: {2}
Explanation: The 1st smallest in [2, 5] is 2.
Your Task:
You don't need to read or print anyhting. Your Task is to complete the function FindQuery() which takes nums and Query as input parameter and returns a list containing kth smallest for every query.
Expected Time Complexity: O(nlog(n))
Expected Space Complexity: O(n)
Constraints:
1 <= n <= 15000
1 <= nums[i] <= n
1 <= no. of queries <= 10^{4}
1 <= l <= r <= n
1 <= k <= r-l+1
输入格式
见题面
输出格式
见题面