Medium
String
Prefix Sum
2483. Minimum Penalty for a Shop
You are given the customer visit log of a shop represented by a 0-indexed string customers
consisting only of characters 'N'
and 'Y'
:
'Y'
, it means that customers come at the ith hour'N'
indicates that no customers come at the ith hour.If the shop closes at the jth hour (0 <= j <= n
), the penalty is calculated as follows:
1
.1
.Return the earliest hour at which the shop must be closed to incur a minimum penalty.
Note that if a shop closes at the jth hour, it means the shop is closed at the hour j
.
Example 1:
Example 2:
Example 3:
Constraints:
customers.length
<= 105customers
consists only of characters 'Y'
and 'N'
.Jerry Wu
JimAug 29, 2023