← All problemsSign in

3228. Maximum Number of Operations to Move Ones to the End

LeetCodeStringGreedyCountingOpen on judge ↗

You are given a binary string s. You can perform the following operation on the string any number of times: - Choose any index i from the string where i + 1 < s.length such that s[i] == '1' and s[i + 1] == '0'. - Move the character s[i] to the right until it reaches the end of the string or another '1'. For example, for s = "010010", if we choose i = 1, the resulting string will be s = "000110"

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start