Skip to content

Commit a5505e1

Browse files
committed
update: 001
1 parent 2d53c02 commit a5505e1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

note/001/README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ class Solution {
4444
```java
4545
class Solution {
4646
public int[] twoSum(int[] nums, int target) {
47-
int len = nums.length;
47+
final int len = nums.length;
4848
HashMap<Integer, Integer> map = new HashMap<>();
4949
for (int i = 0; i < len; ++i) {
50-
if (map.containsKey(nums[i])) {
51-
return new int[]{map.get(nums[i]), i};
50+
final Integer value = map.get(nums[i]);
51+
if (value != null) {
52+
return new int[] { value, i };
5253
}
5354
map.put(target - nums[i], i);
5455
}

0 commit comments

Comments
 (0)