Skip to content
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

Simplified and a bit more optimized solution #154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FusionX9000
Copy link

@FusionX9000 FusionX9000 commented Jan 16, 2020

Using map's getOrDefault significantly reduces conditional checks required. I have also modified the solution a bit to only require a single pass. Further, since we're adding the results in a single pass, we don't care about swapping/changing indexes before the current index, which also halves hash table modifications required.

This is my first pull request, so I apologize in advance if I made a mistake.

@tsunghsienlee
Copy link
Collaborator

Hi @FusionX9000 ,

Very good solution to simplify the code, and I am impressed. We will merge that in the future, and please be patient on this.

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.

None yet

2 participants