Your videos teach a lot to me. It's not just solution of problem. I get to know how you think, how you correct logic when not working. Please keep uploading videos. Thanks a lot Sir.
@@Harisamsharma Yes indeed, there are tons of videos about the solutions and all, but getting to know how a CM thinks during contest, how calm he is, how he handles when going in the right direction . Very helpful...keep it up
@@sagemode6090 we want the minimum value of score, i.e. (low + high), low can be easily calculated to be 0. so we only want to minimize high. Eg.- [1,2,3,4,5] in this high will be 4. so if we want to minimize high, we need to change the [n-1] with [2] or [n-2] with [1] or [n-3] with [0]. Its actually pretty easy if u just look at it.
we want the minimum of (min + high). we can replace any two values. so let's make cases here - 1) we replace the first and the last values i.e. we replace nums[0] with nums[1] and nums[n-1] with nums[n-2] i.e. the difference = nums[n-2] - nums[1] 2) we replace the first two values i.e. we replace nums[0] with nums[2] and nums[1] with nums[2] as well i.e. difference = nums[n-1] - nums[2] 2) we replace the last two values i.e. we replace nums[n-1] with nums[n-3] and nums[n-2] with nums[n-3] as well i.e. difference = nums[n-3] - nums[0 we return the minimum of above
God bhai
can I use ur segment tree code in contests? And also please share it.
Goat
Legend
Your videos teach a lot to me.
It's not just solution of problem.
I get to know how you think, how you correct logic when not working.
Please keep uploading videos.
Thanks a lot Sir.
Glad to hear it :)
@@Harisamsharma Yes indeed, there are tons of videos about the solutions and all, but getting to know how a CM thinks during contest, how calm he is, how he handles when going in the right direction . Very helpful...keep it up
This is what happens when rangey stops his poetry in between contest 😂
what is the intuition behind soln for 2nd?
same doubt like why we have to take that difference
?
@@sagemode6090 we want the minimum value of score, i.e. (low + high), low can be easily calculated to be 0. so we only want to minimize high. Eg.- [1,2,3,4,5] in this high will be 4. so if we want to minimize high, we need to change the [n-1] with [2] or [n-2] with [1] or [n-3] with [0]. Its actually pretty easy if u just look at it.
we want the minimum of (min + high). we can replace any two values. so let's make cases here -
1) we replace the first and the last values i.e. we replace nums[0] with nums[1] and nums[n-1] with nums[n-2] i.e. the difference = nums[n-2] - nums[1]
2) we replace the first two values i.e. we replace nums[0] with nums[2] and nums[1] with nums[2] as well i.e. difference = nums[n-1] - nums[2]
2) we replace the last two values i.e. we replace nums[n-1] with nums[n-3] and nums[n-2] with nums[n-3] as well i.e. difference = nums[n-3] - nums[0
we return the minimum of above