020-004-009
Task Queue Management with ArrayDeque
Medium
Problem Description
Task Queue Management with ArrayDeque
In this problem: You will create a program that uses ArrayDeque<String> as a FIFO (First-In, First-Out) queue to add tasks, process them in order using poll(), display processed tasks, and output the remaining task count.
Learning Objective: Understand how to correctly use ArrayDeque as a queue (FIFO)
Overview
Read multiple task names from standard input and manage them using ArrayDeque as a queue. After adding all tasks to the queue, process a specified number of tasks from the front using poll(), then display processed tasks and the remaining count.
Specifications
- Line 1: Total number of tasks
n - Lines 2 to n+1: Task names (one per line)
- Last line: Number of tasks to process
k - Use
offer()to add tasks to the queue - Use
poll()to removektasks from the front - Output processed tasks and remaining task count
Output Format
Processed: [task1]
Processed: [task2]
...
Remaining tasks: [count]
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