public: int findPlatform(int arr[], int dep[], int n) { sort ( arr,arr+n);sort ( dep , dep+n); int i=0;int j=0;int count=0,maxCount=0; while ( i<n&&j<n){ if ( arr[i]<=dep[j]) {count++;i++;} else {count--;j++;} maxCount=max(count,maxCount); } return maxCount; } };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter