Description The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 21 is read off as "one 2, then one 1" or …
Yet Another Source Code for LintCode Current Status : 232AC / 289ALL in Language C++, Up to date (2016-02-10) For more problems and solutions, you can see my LintCode repository. I'll keep updating for full summary and better solutions. See cnblogs t…
----------------------------------- Moore's voting algorithm算法:从一个集合中找出出现次数半数以上的元素,每次从集合中去掉一对不同的数,当剩下一个元素的时候(事实上只要满足一个元素出现过半就一定会剩下一个元素的)这个元素就是我们要找的数了. AC代码: public class Solution { /** * @param nums: a list of integers * @return: find a majority numb…
-------------------- 递归那么好为什么不用递归啊...我才不会被你骗...(其实是因为用惯了递归啰嗦的循环反倒不会写了...o(╯□╰)o) AC代码: /** * Definition of TreeNode: * public class TreeNode { * public int val; * public TreeNode left, right; * public TreeNode(int val) { * this.val = val; * this.left…