Skip to content

Commit 0c19bd6

Browse files
add 1342
1 parent d7c5b2a commit 0c19bd6

File tree

7 files changed

+25
-5
lines changed

7 files changed

+25
-5
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -635,4 +635,5 @@ LeetCode
635635
|1337|[The K Weakest Rows in a Matrix](https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix/)|c|[c++](./src/1337-The-K-Weakest-Rows-in-a-Matrix/1337.cpp)|[python](./src/1337-The-K-Weakest-Rows-in-a-Matrix/1337.py)|[go](./src/1337-The-K-Weakest-Rows-in-a-Matrix/1337.go)|[js](./src/1337-The-K-Weakest-Rows-in-a-Matrix/1337.js)|[java](./src/1337-The-K-Weakest-Rows-in-a-Matrix/1337.java)|Easy|
636636
|1338|[Reduce Array Size to The Half](https://leetcode.com/problems/reduce-array-size-to-the-half/)|c|[c++](./src/1338-Reduce-Array-Size-to-The-Half/1338.cpp)|[python](./src/1338-Reduce-Array-Size-to-The-Half/1338.py)|[go](./src/1338-Reduce-Array-Size-to-The-Half/1338.go)|[js](./src/1338-Reduce-Array-Size-to-The-Half/1338.js)|[java](./src/1338-Reduce-Array-Size-to-The-Half/1338.java)|Medium|
637637
|1339|[Maximum Product of Splitted Binary Tree](https://leetcode.com/problems/maximum-product-of-splitted-binary-tree/)|c|[c++](./src/1339-Maximum-Product-of-Splitted-Binary-Tree/1339.cpp)|[python](./src/1339-Maximum-Product-of-Splitted-Binary-Tree/1339.py)|[go](./src/1339-Maximum-Product-of-Splitted-Binary-Tree/1339.go)|[js](./src/1339-Maximum-Product-of-Splitted-Binary-Tree/1339.js)|[java](./src/1339-Maximum-Product-of-Splitted-Binary-Tree/1339.java)|Medium|
638-
|1340|[Jump Game V](https://leetcode.com/problems/jump-game-v/)|c|[c++](./src/1340-Jump-Game-V/1340.cpp)|[python](./src/1340-Jump-Game-V/1340.py)|[go](./src/1340-Jump-Game-V/1340.go)|[js](./src/1340-Jump-Game-V/1340.js)|[java](./src/1340-Jump-Game-V/1340.java)|Hard|
638+
|1340|[Jump Game V](https://leetcode.com/problems/jump-game-v/)|c|[c++](./src/1340-Jump-Game-V/1340.cpp)|[python](./src/1340-Jump-Game-V/1340.py)|[go](./src/1340-Jump-Game-V/1340.go)|[js](./src/1340-Jump-Game-V/1340.js)|[java](./src/1340-Jump-Game-V/1340.java)|Hard|
639+
|1342|[Number of Steps to Reduce a Number to Zero](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero/)|c|[c++](./src/1342-Number-of-Steps-to-Reduce-a-Number-to-Zero/1342.cpp)|[python](./src/1342-Number-of-Steps-to-Reduce-a-Number-to-Zero/1342.py)|[go](./src/1342-Number-of-Steps-to-Reduce-a-Number-to-Zero/1342.go)|[js](./src/1342-Number-of-Steps-to-Reduce-a-Number-to-Zero/1342.js)|[java](./src/1342-Number-of-Steps-to-Reduce-a-Number-to-Zero/1342.java)|Easy|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution
2+
{
3+
public:
4+
int numberOfSteps (int num)
5+
{
6+
return num == 0 ? 0 : 1 + numberOfSteps(num & 1 ? num - 1 : num >> 1);
7+
}
8+
};

src/1342-Number-of-Steps-to-Reduce-a-Number-to-Zero/1342.go

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Solution {
2+
public int numberOfSteps (int num) {
3+
return num == 0 ? 0 : 1 + numberOfSteps(num % 2 == 1 ? num - 1 : num >> 1);
4+
}
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var numberOfSteps = function(num) {
2+
return num == 0 ? 0 : 1 + numberOfSteps(num & 1 ? num - 1 : num >> 1);
3+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Solution:
2+
def numberOfSteps (self, num: int) -> int:
3+
return 0 if not num else 1 + self.numberOfSteps(num >> 1 if num % 2 == 0 else num - 1)

src/addProb.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
import os, bisect
33

44
# 题目名称
5-
name = "Partition Equal Subset Sum"
6-
ID = 416
7-
url = "https://leetcode.com/problems/partition-equal-subset-sum/"
8-
difficult = "Medium"
5+
name = "Number of Steps to Reduce a Number to Zero"
6+
ID = 1342
7+
url = "https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero/"
8+
difficult = "Easy"
99
prog = ['c', 'cpp', 'py', 'go', 'js', 'java']
1010

1111

0 commit comments

Comments
 (0)