Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Since seats are allocated by smallest row and then by smallest seat numbers, how can we keep a record of the smallest seat number vacant in each row?
How can range max query help us to check if contiguous seats can be allocated in a range?
Similarly, can range sum query help us to check if enough seats are available in a range?
Which data structure can be used to implement the above?