Most Frequent in a Slice — Solution & Editorial
Range mode has no easy prefix structure; the intended solution is Mo's algorithm (sort queries by √-blocks, maintain a frequency map and a bucketed max). At the provided sizes, counting each queried slice is acceptable.
Complexity: O((N + Q)√N) with Mo's algorithm