Skip to content

Bug Report for permutation-string #3959

Closed
@GentiLicenji

Description

@GentiLicenji

Bug Report for https://neetcode.io/problems/permutation-string

Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.

I gave this function: private void permute(String prefix, String str, Set permutations) {
int n = str.length();
if (n == 0) {
permutations.add(prefix);
} else {
for (int i = 0; i < n; i++) {
permute(prefix + str.charAt(i),
str.substring(0, i) + str.substring(i + 1, n),
permutations);
}
}
}

and the error below came:

Runtime Error (NZEC)

Passed test cases: 5 / 26

stderr

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

If you're getting a Runtime Error (NZEC) and the program is being killed, it's likely due to memory constraints or stack overflow with larger inputs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions