package leetcode;

/**
 * https://leetcode.com/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/
 */
public class Problem1404 {
    public int numSteps(String s) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1404 prob = new Problem1404();
        System.out.println(prob.numSteps("1101")); // 6
        System.out.println(prob.numSteps("10")); // 1
        System.out.println(prob.numSteps("1")); // 0
    }
}

@@ -12,16 +12,46 @@
 tcode;%0A%0A
+import java.math.BigInteger;%0A%0A
 /**%0A * h
@@ -226,294 +226,370 @@
     
-// TODO%0A        return 0
+int answer = 0;%0A        BigInteger n = new BigInteger(s, 2)
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1404 prob = new Problem1404();%0A        System.out.println(prob.numSteps(%221101%22)); // 6%0A        System.out.println(prob.numSteps(%2210%22)); // 1%0A        System.out.println(prob.numSteps(%221%22)); // 0
+while (!n.equals(BigInteger.ONE)) %7B%0A            if (n.mod(BigInteger.valueOf(2)).equals(BigInteger.ZERO)) %7B%0A                n = n.divide(BigInteger.valueOf(2));%0A            %7D else %7B%0A                n = n.add(BigInteger.ONE);%0A            %7D%0A            answer++;%0A        %7D%0A        return answer;
 %0A   

Solve problem 1404