Skip to content

Refactor: merge ReverseStackUsingRecursion into ReverseStack and update tests (#6474) #6480

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions .devcontainer/Dockerfile

This file was deleted.

47 changes: 0 additions & 47 deletions .devcontainer/devcontainer.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you remove this file? Please revert this deletion.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out — I’ll restore the file. I had removed it because it seemed duplicate, but I’ll revert the deletion as requested.

This file was deleted.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please solve the linting issues in this file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it — I’ll fix the linting issues and update the PR.

Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,19 @@ private ReverseStack() {
*
* @param stack the stack to reverse; should not be null
*/
public static void reverseStack(Stack<Integer> stack) {
if (stack.isEmpty()) {
return;
}

int element = stack.pop();
reverseStack(stack);
insertAtBottom(stack, element);
public static void reverseStack(Stack<Integer> stack) {
if (stack == null) {
throw new IllegalArgumentException("Stack cannot be null");
}
if (stack.isEmpty()) {
return;
}

int element = stack.pop();
reverseStack(stack);
insertAtBottom(stack, element);
}

/**
* Inserts the specified element at the bottom of the stack.
*
Expand Down

This file was deleted.

This file was deleted.