Sponsored
Sponsored
Solve with full IDE support and test cases
Use these hints if you're stuck. Try solving on your own first.
The constraints are not very large. Can we simulate the execution by starting from each index of s?
Before any of the stopping conditions is met, stop the simulation for that index and set the answer for that index.