Uber | OA | Haunted Hous
3426

There are N people who want to visit the haunted house. The person will only go if at least L other people will go with him. Additionally, that person doesn't want to go with more than R other people, since it would ruin the experience for them.
What is the maximum number of people that can visit the haunted house at one time so that no constraint is violated?

Sample Input:

// The number of people
	6 
//  L R
	1 2
	1 4
	0 3
	0 1
	3 4
	0 2

Sample Output

3
Comments (9)