LightOj 1088 (Points in Segments)
#lightoj #cp #problem_solving #binary_search
Idea
Binary Search
- Within time complexity only thing to do is binary search i.e use the lower_bound or the upper bound function to find the value of the index .
- lower_bound : points to the first number equals to the ‘num’ or greater than the ‘num’
- upper_bound : points to the first number greater than the ‘num’
Critical Test Cases (Queries) :
6(present) 10(present) –> r-l+1
5(absent) 10(present) –> r-l+1
5(absent) 9(absent) –> r-l
6(present) 9(absent) –> r-l
1 |
|