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

Update 0242-valid-anagram.py #4

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

Conversation

VarshithaGangula3
Copy link

used sorted list

@mdmzfzl
Copy link
Owner

mdmzfzl commented Dec 5, 2024

Thank you for making a PR! But sorted list has a time complexity of O(n log n) compared to frequency map approach which is O(n). So for larger inputs, the original solution is more efficient.

That said, your approach is more concise and readable, so you could add it as an alternative solution or a comment in the code. Feel free to update the PR accordingly. Don't forget to format the code and let me know if you have any more questions!

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