We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Jesse and Cookies
- Discussions
Jesse and Cookies
Jesse and Cookies
Sort by
recency
|
11 Discussions
|
Please Login in order to post a comment
Java O(n log n)
Java 15 solution using PriorityQueue:
C# code
This question is a bit of a joke for Python3.
If you use heapq it works. If you create your own minheap class it times out.
I even copied the custom MinHeap class from GeeksforGeeks and it still failed the tests. Why on earth would heapq work but making a MinHeap class not work? The test cases should be revised so that custom minheap can work for this, which is what you may be tested on in an interview. As in, an interviewer may not allow you to use built-ins like heapq because it doesn't test if you know how to make a heap from scratch.
I say this because I have had interviews where the interviewer didn't allow you to use fancy built-ins to answer their questions.