Piet Souris wrote:how many trains arrive between any two consecutive departures?
I don't think that will quite do it Piet. Take the following example, where "a" is an arrival, and "d" is a departure and the numbers are the trains in the station.
You only ever have 2 arrivals between consecutive departures, but the maximum at the station is 3.
My first attempt would be to simulate it exactly as it would occur in reality. I'll not write any code just yet, but I'll talk through my thought process.
I have 12 events that happen in chronological order, and I have two event types, arrival, and departure.
I could represent the events as an ordered list, the station as a Stack, an arrival as a Stack Push, and a departure as a Stack Pop. If I kept track of the size of the stack after each event and remembered the max size, I reckon that would give me the answer.
I'm sure there are some more time efficient methods than that but for the specific data set you have provided it'll do just fine.