Code Tricks
作者:互联网
这里写目录标题
Condition
边界
排序过的list
- Input不为None
- Input > list[0] 以及 Input < list[-1]
if not nums or target < nums[0] or target > nums[-1]:
return[-1, -1]
Number
等效Java里Max/Min的式子
themax = float('inf')
themin = float('-inf')
themax = sys.maxsize
themin = sys.minsize
IEEE 754 floating point numbers can represent positive or negative infinity, and NaN (not a number)
x 同时是3和5的倍数
代码保证返回boolean
not (i % 15)
- 0为False,1为True
not 0
就是not false,即最终为True- 公式: not (需要符合**整除%**的判断条件)
Calculation
中间数
常用于二分法的代码
mid = (left + right)>>1
#或者
mid = left + (right - left) // 2
Sparse matrix multiplication
https://stackoverflow.com/questions/13272453/multiplying-numpy-scipy-sparse-and-dense-matrices-efficiently
标签:Code,Java,nums,Tricks,Min,list,mid,left 来源: https://blog.csdn.net/u013302570/article/details/120735773