Sponsored
Use these hints if you're stuck. Try solving on your own first.
The constraints are small, allowing you to iterate over all potential values for <code>ans[i]</code> directly.
Solve with full IDE support and test cases