Pl. help debugging my code
First of all your string decoding is incorrect!
think of this : “34:start:45”
its not necessary that process id or time stamp are single digit, hence you cannot hardcode this.
Also I see incorrect logic in storing time.
if the process starts just push it into stack, otherwise the current process ends, you take start time (from stack top) and end time(current time) and add end-start+1,
now check if some other process is running beneath this process, if yes then this time is reduced from that underlying process.(this can be checked if stack is non empty!)