×

Instructions

Please read the instructions carefully before starting the exam.

Once you start the exam, the timer will begin, and you cannot pause it.

Ensure that you complete and submit your code within the given time if the timer is enabled.


Call Center Queue Management – Queue (Difficulty - Easy)


Call Center Queue Management – Queue Problem

Problem Statement:

A customer service call center handles incoming calls using a First-In-First-Out (FIFO) queue system.

There are two types of operations:

  • CALL <name> — a customer with the given name joins the queue.
  • ANSWER — the agent picks the first customer in the queue and removes them.
Your task is to process a list of operations and return the final queue of customers, separated by commas, in the order they will be served. If the queue is empty at the end, return "EMPTY".

Input:

  • A list of strings where each string is either:
    • "CALL <name>" (name is a single word with only letters)
    • "ANSWER"

Output:

A single string with all remaining customers in the queue, separated by commas. If the queue is empty, return "EMPTY".

Constraints:

  • 0 ≤ operations.length ≤ 10⁵
  • Each name is a non-empty alphabetical string without spaces
  • "ANSWER" does nothing if the queue is empty

Example 1:

input: ["CALL Alice", "CALL Bob", "ANSWER"]
output: "Bob"

Explanation:
Alice enters → [Alice]
Bob enters → [Alice, Bob]
ANSWER → Alice removed → [Bob]
    

Example 2:

input: ["ANSWER", "CALL Tom", "CALL Jerry"]
output: "Tom,Jerry"

Explanation:
ANSWER ignored (queue is empty)
Tom enters → [Tom]
Jerry enters → [Tom, Jerry]
    

Example 3:

input: ["CALL Anna", "ANSWER", "ANSWER"]
output: "EMPTY"

Explanation:
Anna enters → [Anna]
ANSWER → Anna removed → []
ANSWER ignored → []
    

Example 4:

input: ["CALL Eve", "CALL Adam", "CALL Sam", "ANSWER", "ANSWER"]
output: "Sam"

Explanation:
Eve enters → [Eve]
Adam enters → [Eve, Adam]
Sam enters → [Eve, Adam, Sam]
ANSWER → Eve removed → [Adam, Sam]
ANSWER → Adam removed → [Sam]
    


Time Left:



Processing...

Error:


                

Output:

Test Case Result Input Correct Output Your Output




Submission Result