That's a very ordinary Binary Search problem. You want to quickly search where is the boundary between 0s and 1s. You need to print the index of the last 0. The way I code Binary Search is that L is a border which is always VALID to print and R is the border which is INVALID. So, when I print L, its exactly the index of the last 0. At the end of the video, there are more detailed explanations for each problem including D. This is only my implementation of Binary Search, other implementations might work differently. I hope this answers the question.
@@sagnikghoshcr7 This is GitHub Copilot, I had a technical preview a year ago, and I still haven't removed the extension. I don't pay for it now, so I don't have access to it. It's kinda useless to me for competitions, since I write my code faster and clearer without it. :D