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

Implement Heap/Priority Queue Solutions for LeetCode Problems #31

Merged
merged 5 commits into from
Sep 10, 2024

Conversation

atulgoel126
Copy link
Owner

This merge request implements solutions for the following LeetCode problems related to heaps and priority queues:

Q215: Kth Largest Element in an Array
Q378: Kth Smallest Element in a Sorted Matrix
Q692: Top K Frequent Words
Q973: K Closest Points to Origin

Changes

  • Implemented solutions for each problem in their respective Java files.
  • Added corresponding test cases for each solution.
  • Updated README-schedule.md to mark completed problems.
  • Removed unused files and tests for Q759 (Employee Free Time).

Implementation Notes

  • Used Java's PriorityQueue for efficient implementation of heap operations.
  • Ensured proper error handling and edge case management in all solutions.
  • Optimized solutions for time and space complexity where possible.

Testing

Comprehensive test cases have been added for each problem, covering various scenarios including edge cases.
All tests are passing successfully.

Using Priority Queue along with a frequency map
Simplest implementation of PriorityQueue - didn't even need a custom comparator.
This was quite a different use case, and had to think outside the box.
The sorted property meant I could optimize this, but couldn't think of how. I should look at this question again.
Using a priority Queue simplified the problem.
The thing to remember is to not make the same calculations again and again.
Need to redo both of these
@atulgoel126 atulgoel126 merged commit 4e06aaf into main Sep 10, 2024
2 checks passed
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