Practice Minimum Penalty for a Shop
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
customers[i] = Y means customers arrive in hour i, and N means none arrive. Closing at hour j means open before j and closed from j onward. Count one penalty for each open hour without customers and each closed hour with customers. Return the earliest minimum-penalty closing hour from 0 through customers.length.
Source: Minimum Penalty for a Shop on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
customers = "YYNY"
Output
2
# Example 2
Input
customers = "NNNNN"
Output
0
# Example 3
Input
customers = "YYYY"
Output
4
Constraints
1 <= customers.length <= 10^5
customers consists only of characters 'Y' and 'N'.
Related LeetCode Problems
Practice more problems similar to Minimum Penalty for a Shop.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.