Maximum Number of Operations to Move Ones to the End - Practice Coding | SlaveCode
0
0123456789
0
0123456789
:
0
0123456789
0
0123456789
3228. Maximum Number of Operations to Move Ones to the End
Medium
30 Points
String
Greedy
Counting
You are given a binary string s.
You can perform the following operation on the string any number of times:
Return the maximum number of operations that you can perform.
Examples
Example 1
Input: s = "1001101"
Output: 4
Explanation:
We can perform the following operations:
Example 2
Input: s = "00111"
Output: 0
Constraints
1 <= s.length <= 105
s[i] is either '0' or '1'.
3228. Maximum Number of Operations to Move Ones to the End
Medium
30 Points
String
Greedy
Counting
You are given a binary string s.
You can perform the following operation on the string any number of times:
Return the maximum number of operations that you can perform.
Examples
Example 1
Input: s = "1001101"
Output: 4
Explanation:
We can perform the following operations: