Skip to content

Commit 5a68385

Browse files
refactor 1342
1 parent 27b1c0c commit 5a68385

File tree

1 file changed

+0
-33
lines changed

1 file changed

+0
-33
lines changed

src/main/java/com/fishercoder/solutions/_1342.java

-33
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,5 @@
11
package com.fishercoder.solutions;
22

3-
/**
4-
* 1342. Number of Steps to Reduce a Number to Zero
5-
*
6-
* Given a non-negative integer num, return the number of steps to reduce it to zero.
7-
* If the current number is even, you have to divide it by 2, otherwise, you have to subtract 1 from it.
8-
*
9-
* Example 1:
10-
* Input: num = 14
11-
* Output: 6
12-
* Explanation:
13-
* Step 1) 14 is even; divide by 2 and obtain 7.
14-
* Step 2) 7 is odd; subtract 1 and obtain 6.
15-
* Step 3) 6 is even; divide by 2 and obtain 3.
16-
* Step 4) 3 is odd; subtract 1 and obtain 2.
17-
* Step 5) 2 is even; divide by 2 and obtain 1.
18-
* Step 6) 1 is odd; subtract 1 and obtain 0.
19-
*
20-
* Example 2:
21-
* Input: num = 8
22-
* Output: 4
23-
* Explanation:
24-
* Step 1) 8 is even; divide by 2 and obtain 4.
25-
* Step 2) 4 is even; divide by 2 and obtain 2.
26-
* Step 3) 2 is even; divide by 2 and obtain 1.
27-
* Step 4) 1 is odd; subtract 1 and obtain 0.
28-
*
29-
* Example 3:
30-
* Input: num = 123
31-
* Output: 12
32-
*
33-
* Constraints:
34-
* 0 <= num <= 10^6
35-
* */
363
public class _1342 {
374
public static class Solution1 {
385
public int numberOfSteps(int num) {

0 commit comments

Comments
 (0)