Skip to content

Simplified and a bit more optimized solution#154

Open
FusionX9000 wants to merge 1 commit intoadnanaziz:masterfrom
FusionX9000:master
Open

Simplified and a bit more optimized solution#154
FusionX9000 wants to merge 1 commit intoadnanaziz:masterfrom
FusionX9000:master

Conversation

@FusionX9000
Copy link
Copy Markdown

@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
Copy Markdown
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.

2 participants