Help needed for a data structure problem

Revision en1, by rofi93, 2017-01-02 08:55:20

Problem: You are given an array consisting of n elements and q queries in the form of [L,R]. You have to output the maximum occurrences of a number in the segment [L,R] for each query.

How to solve these kind of problems using Segment Tree ?? I can solve this using sqrt decomposition, but got stuck trying to solve using segment tree.

Tags segment tree, sqrt_decomposition, advanced data structure

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English rofi93 2017-01-02 08:55:20 378 Initial revision (published)