Dsa
Queue
Easy
Task Queue Scheduler
You are building a simple task scheduler where tasks are processed in the order they are added. Each task has a name and can be processed in turn. Your program should handle the following commands:
1. `ADD TASK_NAME` - A task with the name `TASK_NAME` is added to the queue.
2. `PROCESS` - The task at the front of the queue is processed. If the queue is empty, print 'No tasks to process.'
3. `SHOW` - Print the name of the task at the front of the queue without removing it. If the queue is empty, print 'No tasks in queue.'
4. `COUNT` - Print the number of tasks currently in the queue.
Example Input:
ADD Task1
ADD Task2
COUNT
PROCESS
SHOW
PROCESS
SHOW
Example Output:
2
Task1
No tasks in queue.
Key concepts
queueschedulingtasks
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now