摘要: 1 class Solution { 2 // you need to treat n as an unsigned value 3 public int hammingWeight(int n) { 4 int res = 0; 5 for(int i = 0; i >>=1; 10 } 11 r... 阅读全文
posted @ 2018-07-31 23:32 jasoncool1 阅读(124) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/sum-of-two-integers/discuss/84277/One-liner-with-detailed-explanation https://stackoverflow.com/questions/9070937/adding 阅读全文
posted @ 2018-07-31 23:22 jasoncool1 阅读(122) 评论(0) 推荐(0) 编辑
摘要: >>>表示无符号右移,左边空出的位以0填充>>=右移赋值>>>=无符号右移赋值<<= 左移赋值<<左移 阅读全文
posted @ 2018-07-31 05:37 jasoncool1 阅读(139) 评论(0) 推荐(0) 编辑
摘要: O(n)的方法,两边开始计算最wide的container, 因为往中间走的话,要想遇到更max的,需要更高的smaller height,因此可以去掉已经计算过的smaller的height。 阅读全文
posted @ 2018-07-31 03:52 jasoncool1 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 对数组的每一个数进行遍历,从这个数之后的数字中找出两个的sum等于这个数的相反数。找出这两个数的方法是从剩下list的两端开始查找,要是两端也就是lo+hi < sum的话lo就往前进一位。这中间也要注意的时,因为不能有重复,因此在找到一组相等的之后要判断lo跟lo+1是否一样,一样的话就要lo++ 阅读全文
posted @ 2018-07-31 03:21 jasoncool1 阅读(160) 评论(0) 推荐(0) 编辑