-
Notifications
You must be signed in to change notification settings - Fork 41
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
我在leetcode中对MinPriorityQueue实例化,然后使用enquene方法报错 #21
Comments
Hi @Heron-Wang Unfortunately, leetcode is using an older version of the PriorityQueue that does not provide a default value for the priority callback when providing an element without priority. I have sent leetcode a support ticket asking them to upgrade their environment version of priority-queue to latest. In the meanwhile, you can resolve that by doing this: provide priority as the same value as the element. const p = new MinPriorityQueue();
p.enquene(3, 3);
console.log(p); Cheers |
I understand ,thanks a lot |
having |
They did not yet. I dropped a message to leetcode support to upgrade to V6. |
You cannot enqueue an array, and you cannot remove a random element, the priority queue is so lame compared to Heap. And you cannot use Heap in LeetCode. So there is no way to work out a best optimise solution with JavaScript during a technical interview which requires print out. If you don't believe me, try LeetCode 480 and 502. Trust me, they will drive you crazy, even though you know how to solve it, but you simply could not run it out. It feels like an invisible hand holds your dick from urinating, and you are suffocating. I wish I choose Python for coding practice, but it's too late. |
Hey, sorry to hear that. first of all, has leetcode upgraded to latest version, which uses a compare function? If not, I really don't understand why despite sending them several messages. Also it's not a lame queue. You should know that this whole project started a simple learning project and it scaled out as time progressed. This wasn't built for leetcode, the decided to use at some version. The Heap is not doing anything different, the queue just has a more common interface. Wha do you mean by "enqueue an array". You can enqueue any element into any queue. And you can convert any array into a queue. And regarding removing any element randomly from the queue, that would not be the queue interface right? The queue removal is by priority here. Even if I added you a "remove" function, it will be based on dequeue. So you should dequeue elements till reaching the one you want out, dequeue it, and then return the other elements back. I will reach out again to leetcode to see what version they use. |
fyi - confirming that I have sent another request to leetcode to urgently upgrade the priority-queue lib to v6. |
They still haven't upgraded it. Sent them couple of times asking to upgrade and explaining in details why. Don't know what else to do. |
Pathetic for LC.
…On Wed, Jan 18, 2023 at 11:17 PM eyas ***@***.***> wrote:
They still haven't upgraded it. Sent them couple of times asking to
upgrade and explaining in details why. Don't know what else to do.
—
Reply to this email directly, view it on GitHub
<#21 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AP7V6UKY552NFW37W64UX33WTACQ3ANCNFSM43FIFQMA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
We can customize the |
我在leetcode中进行对MinPriorityQueue实例化,然后使用enquene方法报错
没有 上面的
p.enquene(3);
会打印出如下信息:使用了
p.enquene(3);
报错信息如下how to solve this problem?
The text was updated successfully, but these errors were encountered: