Skip to content

Conversation

bshivaraj
Copy link

No description provided.

@bshivaraj bshivaraj changed the title Update 242-Valid-Anagram.java Update 242-Valid-Anagram.java Code optimization Jul 11, 2022
Copy link
Collaborator

@mitchellirvin mitchellirvin left a comment

Choose a reason for hiding this comment

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

hi @bshivaraj ! thank you for contributing!

your change appears to be less efficient than the existing solution. the existing solution had a runtime of O(s + 26), which reduces to O(s), where s is the length of the input strings. your proposal is O(s + s + (s * log(s)) + (s * log(s)) + s), which reduces to O(s * log(s)).

if you would like to add your solution as a separate approach, that would be okay! it's a very intuitive solution (sorting then comparing the arrays). see the contributing guidelines for details about best practices for getting your PRs reviewed and merged quickly

@github-actions
Copy link

Stale pull request message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants