When are bisect_left and bisect_right not equal?

后端 未结 5 1336
半阙折子戏
半阙折子戏 2021-02-02 09:17

In my understanding, bisect_left and bisect_right are two different ways of doing the same thing: bisection, one coming from the left and the other coming from the right. Thus,

5条回答
  •  不要未来只要你来
    2021-02-02 09:47

    When the target to locate is in the list, bisect_left, bisect_right return different result.

    For example:

    >>> import bisect
    >>> bisect.bisect_left([1,2,3], 2)
    1
    >>> bisect.bisect_right([1,2,3], 2)
    2
    

提交回复
热议问题