Sponsored
Use these hints if you're stuck. Try solving on your own first.
At any index, the penalty is the sum of prefix count of ‘N’ and suffix count of ‘Y’.
Enumerate all indices and find the minimum such value.
Solve with full IDE support and test cases