We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2d53c02 commit a5505e1Copy full SHA for a5505e1
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