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

Commita5505e1

Browse files
committed
update: 001
1 parent2d53c02 commita5505e1

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
classSolution {
4646
publicint[]twoSum(int[]nums,inttarget) {
47-
int len= nums.length;
47+
finalint len= nums.length;
4848
HashMap<Integer,Integer> map=newHashMap<>();
4949
for (int i=0; i< len;++i) {
50-
if (map.containsKey(nums[i])) {
51-
returnnewint[]{map.get(nums[i]), i};
50+
finalInteger value= map.get(nums[i]);
51+
if (value!=null) {
52+
returnnewint[] { value, i };
5253
}
5354
map.put(target- nums[i], i);
5455
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp