Hi fellas. I am having tough time understanding the solution to this problem. It has a editorial. Although from editorial approach is quite clear, but when I try to read the code of the author, I don’t quite understand it. Points I specifically don’t understand in the authors solution are following:
- How is the segment tree being constructed.
- What is the purpose of the “Root” array.
- And in the “rect” function, why “res” is chosen that way. I mean like upper_bound function of C++.
Other quite good/readable solution, I found was of the user @deneo, here, he also did the same thing.
Please help me!!!