[
math
]
BinarySearch 0363 Line of People
Problem statement
https://binarysearch.com/problems/Line-of-People/
Solution
We have equations x <= b and x <= n - 1 - a, from here we can get answer that x can be in [0, min(b, n - 1 - a)] and we have min(b, n - 1 - a) + 1 options.
Complexity
It is O(1) for time and space.
Code
class Solution:
def solve(self, n, a, b):
return min(b, n - 1 - a) + 1