function findPlatform(arrivals, departures)
sort arrivals ascending
sort departures ascending
platforms := 0
maxPlatforms := 0
i := 0
j := 0
while i < length of arrivals
if arrivals[i] <= departures[j] then
platforms := platforms + 1
i := i + 1
else
platforms := platforms - 1
j := j + 1
maxPlatforms := max(maxPlatforms, platforms)
return maxPlatforms
Time: . Space: extra.