...

/

Solution: Find the Floor and Ceil of a Number in a Sorted List

Solution: Find the Floor and Ceil of a Number in a Sorted List

The review discusses the solution for finding the floor and ceil value of a given number from a sorted list, from basic to extensive level.

Solution: 1

The naive approach to this problem would be:

  1. Traverse the list starting from 0th index to the last index
  2. Compare value at each index lst[i] with the given input integer xx
  3. When you hit the maximum value lesser than equal to xx, store it as the floorfloor value
  4. Similarly, the minimum value greater than equal to xx
...