Skip to content

Bug Report for three-integer-sum #4218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sid-parekar opened this issue Jun 3, 2025 · 1 comment
Open

Bug Report for three-integer-sum #4218

sid-parekar opened this issue Jun 3, 2025 · 1 comment

Comments

@sid-parekar
Copy link

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:

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.

@sid-parekar
Copy link
Author

Looks like there are following two similar issues already reported and still open:
#3948 (Mar 20)
#3959 (Mar 25)

Won't hold my breath for the fix then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant