Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents a1f6cd5 + a5505e1 commit b5c0f14Copy full SHA for b5c0f14
note/001/README.md
@@ -44,11 +44,12 @@ class Solution {
44
```java
45
class Solution {
46
public int[] twoSum(int[] nums, int target) {
47
- int len = nums.length;
+ final int len = nums.length;
48
HashMap<Integer, Integer> map = new HashMap<>();
49
for (int i = 0; i < len; ++i) {
50
- if (map.containsKey(nums[i])) {
51
- return new int[]{map.get(nums[i]), i};
+ final Integer value = map.get(nums[i]);
+ if (value != null) {
52
+ return new int[] { value, i };
53
}
54
map.put(target - nums[i], i);
55
0 commit comments