You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
Get this error consistently:
Runtime Error (NZEC)
run.sh: line 1: 3 Killed /usr/local/jdk17/bin/java --module-path /usr/local/javafx-sdk-22.0.2/lib --add-modules javafx.web,javafx.fxml,javafx.swing,javafx.controls,javafx.media,javafx.base,javafx.graphics Main
With code:
class Solution {
public List<List<Integer>> threeSum(int[] nums) {
List<List<Integer>> result = new ArrayList<>();
Arrays.sort(nums);
for (int i = 0; i < nums.length; i++) {
if (i > 0 && nums[i] == nums[i-1]) {
continue;
}
int left = i + 1, right = nums.length - 1;
int target = 0 - nums[i];
while (left < right) {
if (nums[left] + nums[right] > target) {
right --;
} else if (nums[left] + nums[right] < target) {
left ++;
} else {
result.add(Arrays.asList(i, left, right));
}
}
}
return result;
}
}
But if you comment out either for loop or Arrays.sort(nums) it works. You get this error only if you have both.
The text was updated successfully, but these errors were encountered:
Bug Report for https://neetcode.io/problems/three-integer-sum
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
Get this error consistently:
With code:
But if you comment out either for loop or
Arrays.sort(nums)
it works. You get this error only if you have both.The text was updated successfully, but these errors were encountered: