摘要:
代码长了些,但还是比较简单的 阅读全文
摘要:
注意这里num要%2再与1异或 阅读全文
摘要:
1 public class Solution { 2 public int hammingDistance(int x, int y) { 3 int ans = 0; 4 while (x > 0 || y > 0) { 5 ans += (x % 2) ^ (y % 2); 6 x /= 2... 阅读全文
摘要:
1 /** 2 * Definition for a binary tree node. 3 * public class TreeNode { 4 * int val; 5 * TreeNode left; 6 * TreeNode right; 7 * TreeNode(int x) { val = x; } 8 * } 9 ... 阅读全文
摘要:
1 public class Solution { 2 public boolean canConstruct(String ransomNote, String magazine) { 3 int[] ransomNum = new int[256]; 4 int[] magNum = new int[256]; 5 for (... 阅读全文
摘要:
n-1个element加1相当于一个元素减1,那最少的move就是所有元素减去最小值之和 阅读全文
摘要:
这题参照http://blog.jobbole.com/42550/ 用的蓄水池算法,即更改ans的概率为1/(当前length) 阅读全文