1/11 Test Cases Passed
You need to earn 2 or 3 stars in order to submit.
1/11 Test Cases Passed
You need atleast 2 stars to grade your answer.
class Queue { constructor() { this.head = null; this.tail = null; } //add the given value to the end of the queue enqueue(val) {
} //remove & return value at front of queue. dequeue() {
} //return the value at front of the queue, without removing it front() {
} //return whether given value is found within the queue contains(val) {
} //returns whether our queue contains no values isEmpty() {
} //returns the number of values in our queue. size() {
} //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) { this.value = value; this.next = null; } } let queue = new Queue(); queue.enqueue("Michael"); queue.enqueue("Joseph"); queue.enqueue("Sarah");
Test Cases (0/11)
-
queue.print() to log Michael Joseph Sarah
-
queue.print() to log Joseph Sarah
-
queue.print() to log Sarah
-
queue.size() to return 0
-
queue.front() to return Michael
-
queue.isEmpty() to return false
-
queue.contains("Mike") to return false
-
queue.contains("Sarah") to return true
-
queue.size() to return 3
-
queue.size() to return 2
-
queue.dequeue() to return Michael
queue.dequeue();
queue.dequeue(); queue.dequeue();
queue.dequeue(); queue.dequeue(); queue.dequeue();
queue.dequeue();