Skip to content

Update QuestionA.java#200

Open
mikecelletti wants to merge 1 commit intocareercup:masterfrom
mikecelletti:patch-1
Open

Update QuestionA.java#200
mikecelletti wants to merge 1 commit intocareercup:masterfrom
mikecelletti:patch-1

Conversation

@mikecelletti
Copy link
Copy Markdown

@mikecelletti mikecelletti commented Jun 7, 2020

This change should greatly improve the best case runtime. The current version of the algorithm always sorts both strings before doing any checks. If the strings are not the same length, then they can't be permutations of one another. In cases where they are not the same length, this change will shorten the algorithm's time to O(1) as it only makes a comparison of the strings' length property before returning.

@mikecelletti
Copy link
Copy Markdown
Author

This check is implemented in the alternate answer, and should serve the same purpose here

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