Binary Search
bisect
: https://docs.python.org/3/library/bisect.html. Support for maintaining a list in sorted order without having to sort the list after each insertion.
1 | bisect.bisect_left(a, x, lo=0, hi=len(a)) # Locate the insertion point for `x` in `a` to maintain sorted order. |
611. Valid Triangle Number
Leetcode: https://leetcode.com/problems/valid-triangle-number/
1 | def triangleNumber(self, nums): |