Skip to content

Commit bdefe39

Browse files
committed
feat: add solutions to lc problem: No.1976
No.1976.Number of Ways to Arrive at Destination
1 parent e4704af commit bdefe39

File tree

11 files changed

+578
-118
lines changed

11 files changed

+578
-118
lines changed

solution/0700-0799/0706.Design HashMap/README.md

+6-25
Original file line numberDiff line numberDiff line change
@@ -65,31 +65,18 @@ myHashMap.get(2); // 返回 -1(未找到),myHashMap 现在为 [[1,1]]
6565
class MyHashMap:
6666

6767
def __init__(self):
68-
"""
69-
Initialize your data structure here.
70-
"""
7168
self.data = [-1] * 1000001
7269

7370
def put(self, key: int, value: int) -> None:
74-
"""
75-
value will always be non-negative.
76-
"""
7771
self.data[key] = value
7872

7973
def get(self, key: int) -> int:
80-
"""
81-
Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key
82-
"""
8374
return self.data[key]
8475

8576
def remove(self, key: int) -> None:
86-
"""
87-
Removes the mapping of the specified value key if this map contains a mapping for the key
88-
"""
8977
self.data[key] = -1
9078

9179

92-
9380
# Your MyHashMap object will be instantiated and called as such:
9481
# obj = MyHashMap()
9582
# obj.put(key,value)
@@ -103,26 +90,20 @@ class MyHashMap:
10390

10491
```java
10592
class MyHashMap {
93+
private int[] data = new int[1000001];
10694

107-
private int[] data;
108-
109-
/** Initialize your data structure here. */
11095
public MyHashMap() {
111-
data = new int[1000001];
11296
Arrays.fill(data, -1);
11397
}
114-
115-
/** value will always be non-negative. */
98+
11699
public void put(int key, int value) {
117100
data[key] = value;
118101
}
119-
120-
/** Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key */
102+
121103
public int get(int key) {
122104
return data[key];
123105
}
124-
125-
/** Removes the mapping of the specified value key if this map contains a mapping for the key */
106+
126107
public void remove(int key) {
127108
data[key] = -1;
128109
}
@@ -173,8 +154,8 @@ class MyHashMap {
173154
```cpp
174155
class MyHashMap {
175156
public:
176-
int hash[1000010];
177-
157+
int hash[1000010];
158+
178159
MyHashMap() {
179160
memset(hash, -1, sizeof hash);
180161
}

solution/0700-0799/0706.Design HashMap/README_EN.md

+6-25
Original file line numberDiff line numberDiff line change
@@ -55,31 +55,18 @@ myHashMap.get(2); // return -1 (i.e., not found), The map is now [[1,1]]
5555
class MyHashMap:
5656

5757
def __init__(self):
58-
"""
59-
Initialize your data structure here.
60-
"""
6158
self.data = [-1] * 1000001
6259

6360
def put(self, key: int, value: int) -> None:
64-
"""
65-
value will always be non-negative.
66-
"""
6761
self.data[key] = value
6862

6963
def get(self, key: int) -> int:
70-
"""
71-
Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key
72-
"""
7364
return self.data[key]
7465

7566
def remove(self, key: int) -> None:
76-
"""
77-
Removes the mapping of the specified value key if this map contains a mapping for the key
78-
"""
7967
self.data[key] = -1
8068

8169

82-
8370
# Your MyHashMap object will be instantiated and called as such:
8471
# obj = MyHashMap()
8572
# obj.put(key,value)
@@ -91,26 +78,20 @@ class MyHashMap:
9178

9279
```java
9380
class MyHashMap {
81+
private int[] data = new int[1000001];
9482

95-
private int[] data;
96-
97-
/** Initialize your data structure here. */
9883
public MyHashMap() {
99-
data = new int[1000001];
10084
Arrays.fill(data, -1);
10185
}
102-
103-
/** value will always be non-negative. */
86+
10487
public void put(int key, int value) {
10588
data[key] = value;
10689
}
107-
108-
/** Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key */
90+
10991
public int get(int key) {
11092
return data[key];
11193
}
112-
113-
/** Removes the mapping of the specified value key if this map contains a mapping for the key */
94+
11495
public void remove(int key) {
11596
data[key] = -1;
11697
}
@@ -161,8 +142,8 @@ class MyHashMap {
161142
```cpp
162143
class MyHashMap {
163144
public:
164-
int hash[1000010];
165-
145+
int hash[1000010];
146+
166147
MyHashMap() {
167148
memset(hash, -1, sizeof hash);
168149
}

solution/0700-0799/0706.Design HashMap/Solution.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class MyHashMap {
22
public:
3-
int hash[1000010];
4-
3+
int hash[1000010];
4+
55
MyHashMap() {
66
memset(hash, -1, sizeof hash);
77
}
@@ -25,4 +25,4 @@ class MyHashMap {
2525
* obj->put(key,value);
2626
* int param_2 = obj->get(key);
2727
* obj->remove(key);
28-
*/
28+
*/
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,27 @@
1-
class MyHashMap {
2-
3-
private int[] data;
4-
5-
/** Initialize your data structure here. */
6-
public MyHashMap() {
7-
data = new int[1000001];
8-
Arrays.fill(data, -1);
9-
}
10-
11-
/** value will always be non-negative. */
12-
public void put(int key, int value) {
13-
data[key] = value;
14-
}
15-
16-
/** Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key */
17-
public int get(int key) {
18-
return data[key];
19-
}
20-
21-
/** Removes the mapping of the specified value key if this map contains a mapping for the key */
22-
public void remove(int key) {
23-
data[key] = -1;
24-
}
25-
}
26-
27-
/**
28-
* Your MyHashMap object will be instantiated and called as such:
29-
* MyHashMap obj = new MyHashMap();
30-
* obj.put(key,value);
31-
* int param_2 = obj.get(key);
32-
* obj.remove(key);
1+
class MyHashMap {
2+
private int[] data = new int[1000001];
3+
4+
public MyHashMap() {
5+
Arrays.fill(data, -1);
6+
}
7+
8+
public void put(int key, int value) {
9+
data[key] = value;
10+
}
11+
12+
public int get(int key) {
13+
return data[key];
14+
}
15+
16+
public void remove(int key) {
17+
data[key] = -1;
18+
}
19+
}
20+
21+
/**
22+
* Your MyHashMap object will be instantiated and called as such:
23+
* MyHashMap obj = new MyHashMap();
24+
* obj.put(key,value);
25+
* int param_2 = obj.get(key);
26+
* obj.remove(key);
3327
*/
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
1-
class MyHashMap:
2-
def __init__(self):
3-
"""
4-
Initialize your data structure here.
5-
"""
6-
self.data = [-1] * 1000001
7-
8-
def put(self, key: int, value: int) -> None:
9-
"""
10-
value will always be non-negative.
11-
"""
12-
self.data[key] = value
13-
14-
def get(self, key: int) -> int:
15-
"""
16-
Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key
17-
"""
18-
return self.data[key]
19-
20-
def remove(self, key: int) -> None:
21-
"""
22-
Removes the mapping of the specified value key if this map contains a mapping for the key
23-
"""
24-
self.data[key] = -1
25-
26-
27-
# Your MyHashMap object will be instantiated and called as such:
28-
# obj = MyHashMap()
29-
# obj.put(key,value)
30-
# param_2 = obj.get(key)
31-
# obj.remove(key)
1+
class MyHashMap:
2+
3+
def __init__(self):
4+
self.data = [-1] * 1000001
5+
6+
def put(self, key: int, value: int) -> None:
7+
self.data[key] = value
8+
9+
def get(self, key: int) -> int:
10+
return self.data[key]
11+
12+
def remove(self, key: int) -> None:
13+
self.data[key] = -1
14+
15+
16+
# Your MyHashMap object will be instantiated and called as such:
17+
# obj = MyHashMap()
18+
# obj.put(key,value)
19+
# param_2 = obj.get(key)
20+
# obj.remove(key)

0 commit comments

Comments
 (0)