Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5a68385

Browse files
refactor 1342
1 parent27b1c0c commit5a68385

File tree

1 file changed

+0
-33
lines changed

1 file changed

+0
-33
lines changed

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

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,5 @@
11
packagecom.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
publicclass_1342 {
374
publicstaticclassSolution1 {
385
publicintnumberOfSteps(intnum) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp