020-004-010
Queue Basic Operations
Easy
Problem Description
Queue Basic Operations
In this problem: You will use LinkedList as a Queue interface and perform basic operations with offer/poll/peek.
Learning Objective: Understand basic Queue (FIFO: First In, First Out) operations
Overview
Queue manages data using the FIFO (First In, First Out) principle as a collection. Use offer to add to the tail, poll to remove from the head, and peek to check the head without removing.
Specifications
- Create a
Queue<String>usingLinkedList - Use
offerto add"Alice","Bob","Charlie"in order - Use
peekto check the front element (without removing) and output - Use
polltwice to remove and output - Output the remaining queue size
Output Format
Front: Alice
Polled: Alice
Polled: Bob
Remaining: 1
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up