Skip to content

Fix Java two-stack solution article on minimum-stack.md#5658

Open
edd-1701 wants to merge 2 commits intoneetcode-gh:mainfrom
edd-1701:main
Open

Fix Java two-stack solution article on minimum-stack.md#5658
edd-1701 wants to merge 2 commits intoneetcode-gh:mainfrom
edd-1701:main

Conversation

@edd-1701
Copy link
Copy Markdown

@edd-1701 edd-1701 commented Apr 1, 2026

The existing code sample as-is does not pass.

Equality for non-primitive Integer objects should be checked with .equals()
== is otherwise checking the reference is to the same object

Java has a pitfall where it caches (and reuses) small Integers (-128 to 127) by default. This can make you think == is working as expected.

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

Successfully merging this pull request may close these issues.

1 participant