#3636
Threshold Majority Queries
international master · 2180 · lc hard +32 · 21.7% accepted · 37 likes · top 2%
Description
Given an integer array nums and a list queries where each query is [l, r, threshold], answer each query independently. For query i, look at the subarray nums[l..r] and find the element that appears strictly more than threshold times. If multiple qualify, return the one with the highest count (ties broken by smallest value). If none qualifies, return -1. Return all answers as an array.
Code
1
2
3