text: /**
   * Implement the Queue with a given interface via linked list (use ListNode extension above).
   *
   * @example
   * const queue = new Queue();
   *
   * queue.enqueue(1); // adds the element to the queue
   * queue.enqueue(3); // adds the element to the queue
   * queue.dequeue(); // returns the top element from queue and deletes it, returns 1
   *
   */
  const ListNode = require('../extensions/list-node');
  
  class Queue {
    constructor() {
      this.head = null;
      this.tail = null;
      this.size = 0;
    }
  
    enqueue(elem) {
      const newNode = new ListNode(elem);
      if (!this.size) {
        this.head = newNode;
        this.tail = newNode;
      } else {
        this.tail.next = newNode;
        this.tail = newNode;
      }
      this.size++;
    }
  
    dequeue() {
      if (!this.size) return null;
      this.size--;
      const headValue = this.head.value;
      if (!this.size) {
        this.head = null;
        this.tail = null;
      } else {
        this.head = this.head.next;
      }
  
      return headValue;
    }
  }
  
  module.exports = Queue;
  