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

Commitb5c0f14

Browse files
authored
Merge pull requestBlankj#22 from SCBoyChina/master
update: 001
2 parentsa1f6cd5 +a5505e1 commitb5c0f14

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