Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Since the problem asks for the latest step, can you start the searching from the end of arr?
Use a map to store the current “1” groups.
At each step (going backwards) you need to split one group and update the map.