problem
solution
用二元搜尋尋找左右邊界。
1 | class Solution { |
analysis
- time complexity
O(1)
,因為k最大也就是LONG_MAX
O(log(LONG_MAX) = O(32) = O(1)
- space complexity
O(1)
用二元搜尋尋找左右邊界。
1 | class Solution { |
O(1)
,因為k最大也就是LONG_MAX
O(log(LONG_MAX) = O(32) = O(1)
O(1)