Skip to content

Commit 1de8396

Browse files
committed
Create README - LeetHub
1 parent ff09b4b commit 1de8396

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

Minimum Platforms - GFG/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Minimum Platforms
2+
## Medium
3+
<div class="problems_problem_content__Xm_eO"><p><span style="font-size:18px">Given arrival and departure times of all trains that reach a railway station. Find the minimum number of platforms required for the railway station so that no train is kept waiting.<br>
4+
Consider that all the trains arrive on the same day and leave on the same day. Arrival and departure time can never&nbsp;be the same for a train&nbsp;but we can have arrival time of one train equal to departure time of the other.&nbsp;At any&nbsp;given instance of time, same platform can not be used for both departure of a train and arrival of another train.&nbsp;In such cases,&nbsp;we need different platforms<strong>.</strong></span></p>
5+
6+
<p><br>
7+
<span style="font-size:18px"><strong>Example 1:</strong></span></p>
8+
9+
<pre><span style="font-size:18px"><strong>Input</strong>: n = 6&nbsp;
10+
arr[] = {0900, 0940, 0950, 1100, 1500, 1800}
11+
dep[] = {0910, 1200, 1120, 1130, 1900, 2000}
12+
<strong>Output</strong>: 3
13+
<strong>Explanation</strong>:
14+
Minimum 3 platforms are required to
15+
safely arrive and depart all trains.</span></pre>
16+
17+
<p><span style="font-size:18px"><strong>Example 2:</strong></span></p>
18+
19+
<pre><span style="font-size:18px"><strong>Input</strong>: n = 3
20+
arr[] = {0900, 1100, 1235}
21+
dep[] = {1000, 1200, 1240}
22+
<strong>Output</strong>: 1
23+
<strong>Explanation</strong>: Only&nbsp;1 platform is required to
24+
safely manage the arrival and departure
25+
of all trains.&nbsp;</span>
26+
</pre>
27+
28+
<p><br>
29+
<span style="font-size:18px"><strong>Your Task:</strong><br>
30+
You don't need to read input or print anything. Your task is to complete the function&nbsp;<strong>findPlatform()</strong>&nbsp;which takes the array arr[] (denoting the arrival times), array dep[] (denoting the departure times)&nbsp;and the size of the array as inputs and returns the minimum number of platforms required at the railway station such that no train waits.</span></p>
31+
32+
<p><span style="font-size:18px"><strong>Note:</strong> Time intervals are in the 24-hour format(<strong>HHMM) ,</strong>&nbsp;where the first two characters represent hour (between 00 to 23 ) and the last two characters represent minutes (this may be &gt; 59).</span></p>
33+
34+
<p><br>
35+
<span style="font-size:18px"><strong>Expected Time Complexity:&nbsp;</strong>O(nLogn)<br>
36+
<strong>Expected Auxiliary Space:&nbsp;</strong>O(n)</span></p>
37+
38+
<p><br>
39+
<span style="font-size:18px"><strong>Constraints:</strong><br>
40+
1 ≤ n ≤ 50000<br>
41+
0000 ≤ A[i] ≤ D[i] ≤ 2359</span></p>
42+
</div>

0 commit comments

Comments
 (0)