Snapchat | Parse CPU log file

8781
Aug 12, 2016
Jul 19, 2019

Three columns inside log file generated by single thread CPU, assuming input is Entry(String jobName, boolean start, int timeStamp), output is HashMap<String, List>

write a parse function to parse log file. Please read these two examples below very carefully. This problem is more complicated than I think !

job (String) start/end (boolean) timestamp (Integer)
f1 true 1
f1 true 2
f2 true 4
f2 false 8
f1 false 16
f1 false 32
f3 true 64
f3 false 128

output: f1: [1,4] [8,32]
f2: [4,8]
f3: [64,128}


Another example:
f1 true 0
f2 true 2
f1 true 5
f1 false 7
f2 false 10
f3 true 11
f3 false 12
f1 false 15
f4 true 16
f4 false 19

Output:
f1: [0,2], [5, 7], [10, 11], [12 15]
f2: [2,5], [7, 10]
f3: [11, 12]
f4: [16, 19]

Comments (10)