Implement the following interface:
interface Logger {
/**
* When a process starts, it calls 'start' with processId and startTime.
*/
void start(String processId, long startTime);
/**
* When the same process ends, it calls 'end' with processId and endTime.
*/
void end(String processId, long endTime);
/**
* Prints the logs of this system sorted by the start time of processes in the below format
* {processId} started at {startTime} and ended at {endTime}
*/
void print();
}Example:
Logger log = new MyLogger();
log.start("1", 100);
log.start("2", 101);
log.end("2", 102);
log.start("3", 103);
log.end("1", 104);
log.end("3", 105);
log.print();
Output:
1 started at 100 and ended at 104
2 started at 101 and ended at 102
3 started at 103 and ended at 105