topic:
2251.The number of flowers during the flowering period.md
Thought:
看的answer,The idea is too complicated。Learned a new library,bisect,Two -point search,Can be used to find the insertion position。
bisect_right(a, x)
: List in orderaMediumx,returnxThe position that should be inserted,This position is located inaThe right side of all the same elements。
bisect_left(a, x)
: List in orderaMediumx,returnxThe position that should be inserted,This position is located inaAll of the same elements in the left。
We can usebisect_rightHere,usebisect_leftHere。
Code:
1 | class Solution: |