dharmveercp's blog

By dharmveercp, 5 years ago, In English

Can someone please help me with this problem. Here is my solution. It's giving me wrong answer on test 2. I am applying simple lazy prapogation logic. Can someone help me, It will hardly take 5 minutes of your time.

My logic: Firstly I fill the whole segment tree with -1's. Now, query function is simply finding an element present on a particular index and when we have some update pending in the path from root to this node I will simply assign this value to it's children and current node will have value -1 after this. My english is poor, sorry.

Thanks very much.

Upd: Accepted code

Full text and comments »

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