← All problemsSign in

1404. Number of Steps to Reduce a Number in Binary Representation to One

LeetCodeStringBit ManipulationSimulationOpen on judge ↗

Given the binary representation of an integer as a string s, return the number of steps to reduce it to 1 under the following rules: - If the current number is even, you have to divide it by 2. - If the current number is odd, you have to add 1 to it. It is guaranteed that you can always reach one for all test cases. Example 1: Input: s = "1101" Output: 6 Explanation: "1101" corressponds

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