13421 [LeetCode] 1342 Number of Steps to Reduce a Number to Zero, C Solution Simple sequential calculation Other Solution can use binary operation int numberOfSteps(int num) { int step = 0; while (num != 0) { if (num % 2 == 0) { num = num / 2; } else { num -= 1; } ++step; } return step; } 2022. 12. 28. 이전 1 다음