SpartanWarrior's blog

By SpartanWarrior, history, 2 years ago, In English

Can someone please help me on how to approach this Problem

Thanking you in anticipation.

  • Vote: I like it
  • +4
  • Vote: I do not like it

| Write comment?
»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

for query you can use sparse table or segment tree

»
2 years ago, # |
  Vote: I like it +6 Vote: I do not like it
Hint
Solution
»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it
»
2 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

In tutorial, we can easily get max/min when adding an element, but it's hard to remove an element.

How does the tutorial solve it?

It uses two stacks to implement the queue, and get the result of max/min from two of the stack to get the result.

Can we just replace it with other merge function?