Ad
  • Default User Avatar

    bisect gives the position in a sorted list to insert a new element and keep it sorted.
    Like the name suggest, it uses a bisection algorithm so it's faster than just checking the list one by one.

    The difference between left and right is when the element is already in the list since you could add it to the left or the right and keep the list sorted. It's needed because the range is inclusive. :)

  • Custom User Avatar

    never thought about summing the time up, really smart but can you explain what bisect_right() and bisect_left() do ?
    appreciate it