摘要: 参考链接1和参考链接2public class Solution { public int singleNumber(int[] A) { int[] count = new int[32]; for(int i = 0; i > j) & 1; ... 阅读全文
posted @ 2014-12-28 13:03 江南第一少 阅读(88) 评论(0) 推荐(0)
摘要: public class Solution { public int singleNumber(int[] A) { int result = 0; for(int i = 0; i < A.length; i++) { result = re... 阅读全文
posted @ 2014-12-28 13:01 江南第一少 阅读(99) 评论(0) 推荐(0)
摘要: 两个数组,从两边扫描。题目中,如果rating相等的时候,不要求得到的糖一样,不是很科学。真正面试时要问清楚requirement。public class Solution { public int candy(int[] ratings) { if(ratings == nu... 阅读全文
posted @ 2014-12-28 12:23 江南第一少 阅读(130) 评论(0) 推荐(0)
摘要: 三年前找工作时应该做过这题,现在完全不记得了。参考链接public class Solution { public int canCompleteCircuit(int[] gas, int[] cost) { if(gas == null || cost == null || ... 阅读全文
posted @ 2014-12-28 11:57 江南第一少 阅读(120) 评论(0) 推荐(0)
摘要: 只写了DFS递归版,以后复习时再写BFS,DFS非递归版,戳参考链接。public class Solution { public UndirectedGraphNode cloneGraph(UndirectedGraphNode node) { if(node == null... 阅读全文
posted @ 2014-12-28 11:03 江南第一少 阅读(81) 评论(0) 推荐(0)