Skip to content

Commit e8e6de1

Browse files
committed
Update space complexity comment and improve conditional logic clarity in 3Sum solution
Refine space complexity comment in 3Sum solution for accuracy
1 parent 6e4c3dc commit e8e6de1

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

3sum/dohyeon2.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class Solution {
66
// TC: O(n^2)
7-
// SC: O(1)
7+
// SC: O(n^2)
88
public List<List<Integer>> threeSum(int[] nums) {
99
List<List<Integer>> answer = new ArrayList<List<Integer>>();
1010

@@ -41,11 +41,9 @@ public List<List<Integer>> threeSum(int[] nums) {
4141

4242
left++;
4343
right--;
44-
}
45-
if (sum < 0) {
44+
} else if (sum < 0) {
4645
left++;
47-
}
48-
if (sum > 0) {
46+
} else {
4947
right--;
5048
}
5149
}

0 commit comments

Comments
 (0)