LeetCode 1342. Number of Steps to Reduce a Number to Zero (Java)
class Solution { public int numberOfSteps(int num) { int i=0; int n=num; do{ if(n%2 == 0){ n = n/2; i++; }else if(n%2 != 0){ n = n-1; i++; } } while(n!=0); if(num==0){ i=0; } System.out.println(i); return i; } }