MIN QUERY - SEGMENT TREE

My answer is showing run error.please check’

@Sfo_2302
Please send the code.

@Sfo_2302
This is the updated code.

There were some errors.

  1. In the query function, you wrote the condition for no overlap wrongly because of which it was leading to an infinite loop.
  2. As the array is 0 indexed and the queries are 1 indexed, you have to convert the queries to 0 indexed. Thus pass (l - 1) and (r - 1) as arguments and also pass (idx - 1) as argument when the update is callled.

If my answer was able to resolve your query, please mark the doubt as resolved.

but your code is giving wrong answer on submitting the answer

ok i got it thanks.nice explaination

@Sfo_2302
Did it pass now?
If my answer was able to resolve your query, please mark the doubt as resolved.