1/1 Test Cases Passed
You need to earn 2 or 3 stars in order to submit.
1/1 Test Cases Passed
You need atleast 2 stars to grade your answer.
class PriorityQueue { constructor() { this.head = null; } //add the given value to the appropriate place in the queue add(value, priority) {
} //function to print each value in the queue starting from the head print() { let runner = this.head; while(runner != null){ console.log(runner.value); runner = runner.next; } } } class Node { constructor(value, priority) { this.value = value; this.priority = priority; this.next = null; } } let p_queue = new PriorityQueue(); p_queue.add("eat healthy", 5); p_queue.add("buy a gift for a friend's birthday party next week", 3); p_queue.add("take a shower", 8); p_queue.add("take the test today!", 10);
Test Cases (0/1)
-
p_queue.print() to log take the test today! take a shower eat healthy buy a gift for a friend's birthday party next week