Task Management System
Complete the function below. The function receives the full standard input as a single string and must return the exact standard output lines for the described problem.
Problem: Task Management System (Level 1)
Implement a simple task management system that supports adding tasks and retrieving the list of current tasks.
Commands
ADD_TASK <taskId> "<taskName>" <startTime> <endTime>— Creates a task with the given integertaskId, stringtaskName(always enclosed in double quotes in the input, even if it contains no spaces), integerstartTime, and integerendTime, and stores it in the system. If a task with the sametaskIdalready exists, the command is ignored (no update, no error).GET_TASKS— Prints all tasks currently stored in the system, one per line, in the order they were successfully added (insertion order). If no tasks have been added, this command produces no output lines.
Output Format for GET_TASKS
Each task is printed on its own line in exactly the following format:
Task(id=<taskId>,name=<taskName>,start=<startTime>,end=<endTime>)
where taskName is printed without surrounding quotes.
Task Model
Each task contains:
taskId: unique integer identifiertaskName: string (may contain spaces or special characters)startTime: non-negative integerendTime: non-negative integer, greater than or equal tostartTime
Level 1 does not require conflict or overlap validation.
Complete solveTaskManagementSystem. It has one parameter, String input, containing the full stdin payload. Return the stdout payload as an array of lines, without trailing newline characters.
input = "ADD_TASK 1 \"Email\" 0 5\nGET_TASKS" return = ["Task(id=1,name=Email,start=0,end=5)"]
ADD_TASK 1 "Email" 0 5 followed by GET_TASKS. The task name in the input is enclosed in double quotes. GET_TASKS prints one line per stored task in insertion order using the format Task(id=<taskId>,name=<taskName>,start=<startTime>,end=<endTime>), with the name printed without quotes. Since one task was added, the output is a single line: Task(id=1,name=Email,start=0,end=5).- Number of commands: up to
104. - Number of tasks (successful
ADD_TASKcalls): up to104. taskId: integer in the range[1, 109].startTime,endTime: non-negative integers with0 ≤ startTime ≤ endTime ≤ 109.taskName: a non-empty string enclosed in double quotes in the input; the name itself does not contain double-quote characters.- Duplicate
taskIdinADD_TASK: the command is silently ignored; the existing task is not modified. GET_TASKSwith no stored tasks produces zero output lines.- Tasks in
GET_TASKSoutput are listed in insertion order (the order of successfulADD_TASKcommands). - Multiple
GET_TASKScommands may appear; each prints the full current task list at the time of that command.
public String[] solveTaskManagementSystem(String input) {
// write your code here
}