"Problem" in order to count the number of online users of QQ per second in a day, each time a user offline will generate a record to the file: There are three fields in the record (on-line time, offline time, user name), time in seconds. Now that you have a file that contains the N records generated on that day (n is very large), design an algorithm that counts the number of online users per second of the day based on N Records. (0<= online time & lt; <=24*3600 time)
"Train of thought" create an array change[24*3600] used to record a day, the user changes per second, in the first I second on-line one person change[i]++, in the second line one person change[i]--,change[i] if is positive, This second line is larger than the number of people on the line, and vice versa. Create a online[24*3600] to record the number of people online per second, online[0] = 0 for No. 0 seconds online number 0, calculation method is online[n] = online[n-1] + change[N]