Todo Task Manager Operations
Problem statement
Process a finite ordered sequence of todo-task operations. Each task has a unique integer ID, a title, and one status: new, pending, or resolved.
["CREATE", id, title]creates a task with statusnewand returnsOK, orEXISTSif the ID is already present.["READ", id]returnsid|title|status, orNOT_FOUND.["UPDATE_TITLE", id, title]and["UPDATE_STATUS", id, status]returnOKon success orNOT_FOUND. An invalid status returnsINVALID_STATUSwithout changing the task.["DELETE", id]removes the task and returnsOK, orNOT_FOUND.
Return one result for every operation in input order.
Function
manageTasks(operations: String[][]) → String[]Examples
Example 1
operations = [["CREATE","7","Ship release"],["READ","7"],["UPDATE_STATUS","7","pending"],["READ","7"],["DELETE","7"],["READ","7"]]return = ["OK","7|Ship release|new","OK","7|Ship release|pending","OK","NOT_FOUND"]The task is created, updated, read in both states, deleted, and then no longer exists.
Example 2
operations = [["CREATE","1","Draft"],["CREATE","1","Again"],["UPDATE_STATUS","1","closed"],["READ","1"]]return = ["OK","EXISTS","INVALID_STATUS","1|Draft|new"]A duplicate create and an invalid status leave the original task unchanged.
Constraints
1 <= operations.length <= 10^5.- Task IDs are non-negative 32-bit integers encoded as decimal strings.
- Titles are non-empty and do not contain
|. - Every operation has the exact arity described above.