You are given an integer array nums of length n and q queries. Each query is a pair [l, r] (0-indexed, inclusive).
A subarray nums[l..r] is called alternating-parity if for every index i with l < i <= r, nums[i] and nums[i-1] have different parity (one even, one odd).
For each query [l, r], determine whether nums[l..r] is alternating-parity.
nums
: array of integers
queries
: list of
[l, r]
ans
, where
ans[j]
corresponds to query
queries[j]
.
1 <= n, q <= 2*10^5
0 <= l <= r < n
|nums[i]| <= 10^9
Goal: answer all queries efficiently (faster than checking each subarray element-by-element per query).