[
intervals
]
BinarySearch 0535 Intervals Intersecting at Point
Problem statement
https://binarysearch.com/problems/Intervals-Intersecting-at-Point/
Solution
Just do what is asked: for each segment check if point is inside it.
Complexity
It is O(n)
for time and O(1)
for space.
Code
class Solution:
def solve(self, I, P):
return sum(x <= P <= y for x, y in I)