Loading...
Loading...
You are given an integer array nums and a list queries where each queries[i] = [l, r] is a 0-indexed inclusive range.
For each query, determine whether every value in nums[l..r] is pairwise distinct. Values are pairwise distinct when no value appears more than once in that range.
Return an array with one entry per query, in the same order as queries: 1 if the corresponding range is pairwise distinct, or 0 otherwise.
Input: nums = [1, 2, 1, 3]
queries = [[0, 1],
[0, 2],
[1, 3]]
Output: [1, 0, 1]
Explanation: nums[0..1] = [1,2] has no repeated value, so the answer is 1. nums[0..2] = [1,2,1] repeats the value 1, so the answer is 0. nums[1..3] = [2,1,3] has no repeated value, so the answer is 1.
Input: nums = [5]
queries = [[0, 0]]
Output: [1]
Explanation: A range containing a single value is always pairwise distinct.
Input: nums = [4, 4, 4]
queries = [[0, 2],
[1, 2],
[2, 2]]
Output: [0, 0, 1]
Explanation: nums[0..2] = [4,4,4] repeats 4, so the answer is 0. nums[1..2] = [4,4] repeats 4, so the answer is 0. nums[2..2] = [4] has a single value, so the answer is 1.
nums.length ≤105queries.length ≤105nums.length for each [l, r] in queriesnums[i] ≤109