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

Commit a5505e1

Browse files
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

Lines changed: 4 additions & 3 deletions
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+
finalint 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)

AltStyle によって変換されたページ (->オリジナル) /