Answer: CONTINENTAL AG | Minimum Penalty for a Shop | On-Campus OA (2023)

Answer · Posted Jun 2026

Approach Initially assume the shop closes at hour 0. Every 'Y' contributes to the penalty because the shop is closed. Move the closing time one hour at a time. Passing a 'Y' reduces penalty by 1. Passing a 'N' increases penalty by 1. Keep track of the minimum penalty and its corresponding closing hour. Strategy Count total 'Y' characters. Initialize penalty as total 'Y'. Traverse the string: If current character is 'Y', decrement penalty. Otherwise increment penalty. Update the answer ...

The full answer & interview discussion are available to premium members.

Log in Create a free account