Sponsored
Use these hints if you're stuck. Try solving on your own first.
Where can the 0 be placed in an ideal permutation? What about the 1?
Solve with full IDE support and test cases