AlgoUniversity
  • Go Back
Discussion
Minimize Platforms :

Author

Rishabh Verma

Difficulty Level : Medium

Submissions : 240

Asked In : Factset

Marks :15

: 3 | : 1

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.

Input

First line contains n (number of trains) where ($$$1\le n \le 200000$$$).

Second line contains n space separated integers $$$A_i$$$ (Arrival time of $$$ith$$$ train) such that ($$$1 \le A_i \le 1e6$$$).

Third line contains n space separated integers $$$B_i$$$ (Departure time of $$$ith$$$ train) such that ($$$1 \le B_i \le 1e6$$$).

Output

Print a single integer denoting the number platforms we needed such that no train have to wait.

Examples

Input
6
900 940 950 1100 1500 1800
910 1200 1120 1130 1900 2000
Output
3
Input
4
100 200 300 400
200 300 400 500
Output
2

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.