NeetCode #140LC-2483MediumArrays & Hashing
← Back to All Problems#140 · #2483 · Minimum Penalty for a Shop(商店的最少代价)
📌 Problem Statement & Constraints
A shop owner wants to choose an hour
i to close, so that the penalty is minimised. The penalty is the number of 'N' customers before or at hour i plus the number of 'Y' customers after hour i. Given the string customers, return the earliest hour that minimises the penalty. Constraints: 1 <= customers.length <= 10^5.🔒
Sign In to Unlock Full Solutions for All 973 Problems
Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!