Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Implement Queue Using Linked List

MediumPython00:00
I
Practice interviewer
In session
5 left
00:00

Your question is Implement Queue Using Linked List. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Implement a queue using a singly linked list. Your queue should support the following operations:

  1. enqueue(value: int): Add an item to the end of the queue.
  2. dequeue() -> int: Remove and return the item from the front of the queue. If the queue is empty, return -1.
  3. is_empty() -> bool: Check if the queue is empty.

Constraints

  • The queue can have at most 10^5 elements
  • All values are integers

Function Signature

def enqueue(value: int) -> None:
def dequeue() -> int:
def is_empty() -> bool:
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output