Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.分析不能用除法,所以使用减法不断减 除数,同时对 除数 倍乘,进行加速除数:3 ... ...
分类:
其他好文 时间:
2017-02-04 18:15:50
阅读次数:
154
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find th ...
分类:
其他好文 时间:
2017-01-17 07:51:37
阅读次数:
155
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find th ...
分类:
其他好文 时间:
2017-01-17 07:46:30
阅读次数:
198
规律:i等于二的N次幂时,Hamming weight为 1.HammingWeight(2) = 1HammingWeight(3) = HammingWeight(2) + HammingWeight(1) = 2......HammingWeight(8) = 1HammingWeight(9... ...
分类:
其他好文 时间:
2017-01-16 22:30:36
阅读次数:
198
在bootstrap的3.0版本及以上时,菜单的创建有所改变。 现在,我们只需记住3个类 dropdown open dropdown-menu。 前两个是为ul 列表的父元素用的,最后一个是给ul 用的。 现在直接上代码。 效果如下: 现在稍微升级下,如果想给菜单也小小的分个类呢? 这将用到 .d ...
分类:
其他好文 时间:
2017-01-16 18:03:23
阅读次数:
197
之前写过一篇,这是第二篇。上一篇用了多种编程语言来做,这一次是以学算法为主,所以打算都用python来完成。 4. Median of Two Sorted Arrays There are two sorted arrays nums1 and nums2 of size m and n resp ...
分类:
其他好文 时间:
2017-01-15 21:29:47
阅读次数:
173
题意:不用乘除求余运算,计算除法,溢出返回INT_MAX。 首先考虑边界条件,什么条件下会产生溢出?只有一种情况,即返回值为INT_MAX+1的时候。 不用乘除求余怎么做? 一.利用减法。 耗时太长,如果被除数是INT_MIN,除数是1的时候,要循环-INT_MIN次 二.利用位运算 思路来自:ht ...
分类:
其他好文 时间:
2017-01-13 14:01:15
阅读次数:
153
1.05 腊八节 一直都想知道滚动监听是怎么做出来的,今天终于扒拉出来了,在使用的时候只要加上div定位就可以了。。。 ...
分类:
其他好文 时间:
2017-01-05 21:44:59
阅读次数:
175
这道题目一直不会做,因为要考虑的corner case 太多。 1. divisor equals 0. 2. dividend equals 0. 3. Is the result negative? 4. when dividend equals Integer.MIN_VALUE and di ...
分类:
其他好文 时间:
2016-12-27 14:08:13
阅读次数:
169
部分内容引自myt论文:树状数组延伸和离线优化(CDQ、整体二分和莫队) 大致思路 1.确定答案范围[L,R],mid=L+R>>1;2.算出答案在[L,mid]内的操作对答案在[mid+1,R]内的操作的贡献;3.将答案在[L,mid]内的操作放入队列Q1,solve(Q1,L,mid)将答案在[ ...
分类:
其他好文 时间:
2016-12-26 21:22:38
阅读次数:
186