| 1 | Sort arrivals and departures | 0 | 0 | 0 | 0 | Arrivals: [900, 940, 950, 1100, 1500, 1800]
Departures: [910, 1120, 1130, 1200, 1900, 2000] |
| 2 | Compare arrival[0]=900 < departure[0]=910 | 0 | 0 | 1 | 1 | Platform needed for train arriving at 900 |
| 3 | Move i to 1 | 1 | 0 | 1 | 1 | Platforms still 1 |
| 4 | Compare arrival[1]=940 < departure[0]=910 | 1 | 0 | 1 | 1 | No, arrival > departure, so free platform |
| 5 | Move j to 1, decrement platforms to 0 | 1 | 1 | 0 | 1 | Train departed at 910, platform freed |
| 6 | Compare arrival[1]=940 < departure[1]=1120 | 1 | 1 | 1 | 1 | New train arrives, platform needed |
| 7 | Move i to 2 | 2 | 1 | 1 | 1 | Platforms 1 |
| 8 | Compare arrival[2]=950 < departure[1]=1120 | 2 | 1 | 2 | 2 | Another train arrives before previous departs, platform needed |
| 9 | Move i to 3 | 3 | 1 | 2 | 2 | Platforms 2 |
| 10 | Compare arrival[3]=1100 < departure[1]=1120 | 3 | 1 | 3 | 3 | Third train arrives before departure, platform needed |
| 11 | Move i to 4 | 4 | 1 | 3 | 3 | Platforms 3 |
| 12 | Compare arrival[4]=1500 < departure[1]=1120 | 4 | 1 | 3 | 3 | No, arrival > departure, free platform |
| 13 | Move j to 2, decrement platforms to 2 | 4 | 2 | 2 | 3 | Train departed at 1120, platform freed |
| 14 | Compare arrival[4]=1500 < departure[2]=1130 | 4 | 2 | 2 | 3 | No, arrival > departure, free platform |
| 15 | Move j to 3, decrement platforms to 1 | 4 | 3 | 1 | 3 | Train departed at 1130, platform freed |
| 16 | Compare arrival[4]=1500 < departure[3]=1200 | 4 | 3 | 1 | 3 | No, arrival > departure, free platform |
| 17 | Move j to 4, decrement platforms to 0 | 4 | 4 | 0 | 3 | Train departed at 1200, platform freed |
| 18 | Compare arrival[4]=1500 < departure[4]=1900 | 4 | 4 | 1 | 3 | New train arrives, platform needed |
| 19 | Move i to 5 | 5 | 4 | 1 | 3 | Platforms 1 |
| 20 | Compare arrival[5]=1800 < departure[4]=1900 | 5 | 4 | 2 | 3 | Another train arrives before departure, platform needed |
| 21 | Move i to 6 | 6 | 4 | 2 | 3 | Platforms 2 |
| 22 | No more arrivals, move j to 5, decrement platforms to 1 | 6 | 5 | 1 | 3 | Train departed at 1900, platform freed |
| 23 | No more arrivals, move j to 6, decrement platforms to 0 | 6 | 6 | 0 | 3 | Train departed at 2000, platform freed |
| 24 | All trains processed | 6 | 6 | 0 | 3 | Minimum platforms needed is 3 |