AlgoUniversity
  • Go Back
Discussion
Gold Jumps :

Author

Manas

Difficulty Level : Medium

Submissions : 195

Asked In : Bhanzu

Marks :10

: 7 | : 0

We got the news that someone was jumping on the positive integer line holding a bag of gold coins. While jumping, he always dropped a gold coin at each position from the start to the end of his jump. We can visit only an integer place and collect the gold coins at that position.

Find the smallest position with the maximum number of coins.

You are given n start and end points corresponding to each jump, in array st[] are the start points and array end[] are the corresponding end points.

Constraints:

1 <= n <= 100000 1 <= st[i] <= 10^9 1 <= end[i] <= 10^9

Input

First line contains and integer n . This is followed by 2 lines The next line contains n space separated integers corresponding to the start position of the jump. The next line contains n space separated integers corresponding to the end position of the respective jump

Output

Output the smallest position which has the maximum number of coins

Example

Input
4
1 3 2 10
8 4 5 11
Output
3

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.