*Minimum Platforms

Problem Link: https://practice.geeksforgeeks.org/problems/minimum-platforms-1587115620/1

class Solution:    
    #Function to find the minimum number of platforms required at the
    #railway station such that no train waits.
    def minimumPlatform(self,n,arr,dep):
        # code here
        
        arr.sort()
        dep.sort()
        
        i=0
        j=0
        c=0
        ans=0
        
        while(i<n):
            if(arr[i]<=dep[j]):
                c+=1
                i+=1
                ans=max(ans,c)
            else:
                c-=1
                j+=1
                
        return ans

Last updated