Advertisement
Iam_Sandeep

Meeting Rooms or No Of Platforms No Of Party Halls

Jul 2nd, 2022
815
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None
  1. #Function to find the minimum number of platforms required at the
  2.     #railway station such that no train waits.
  3. def minimumPlatform(n,arr,dep):
  4.     i=0
  5.     j=0
  6.     arr.sort()
  7.     dep.sort()
  8.     res=pf=0
  9.     while i<n     and j<n:
  10.         if arr[i]<=dep[j]:
  11.             i=i+1
  12.             pf+=1
  13.             res=max(pf,res)
  14.         else:
  15.             j=j+1
  16.             pf-=1
  17.             return res
Advertisement
RAW Paste Data Copied
Advertisement