Skip to content

Update 0347-top-k-frequent-elements.rs #1875

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

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

Conversation

nirajvenkat
Copy link
Contributor

My proposal for an updated solution. This is similar to the Python solution that is O(n) time. Partition/quick select algorithm is longer and harder to read.

Comparison of compiler output (my proposed solution has fewer instructions): Old: https://rust.godbolt.org/z/ofo3o8jT5
New: https://rust.godbolt.org/z/cTG38984T

My proposal for an updated solution. This is similar to the Python solution that is O(n) time.
Partition/quick select algorithm is longer and harder to read.

Comparison of compiler output (my proposed solution has fewer instructions):
Old: https://rust.godbolt.org/z/ofo3o8jT5
New: https://rust.godbolt.org/z/cTG38984T

Submission URL: https://leetcode.com/problems/top-k-frequent-elements/submissions/871042505/
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