摘要:
一次遍历就可以 https://www.cnblogs.com/wingyip/archive/2016/05/18/5507089.html 阅读全文
摘要:
最开始写成int i,j = 0;就报错了 http://www.cnblogs.com/grandyang/p/5533305.html 阅读全文
摘要:
class Solution { public: vector fizzBuzz(int n) { vector result; if(n <= 0) return result; for(int i = 1;i <= n;i++){ if(i%15 == 0) ... 阅读全文
摘要:
House Robber:不能相邻,求能获得的最大值 House Robber II:不能相邻且第一个和最后一个不能同时取,求能获得的最大值 House Robber III:二叉树下的不能相邻,求能获得的最大值 Paint House:用3种颜色,相邻的房屋不能用同一种颜色,求花费最小 Paint 阅读全文
摘要:
和剑指offer上有个题很像,但当时没考虑到比如只有cc,整个字符完全都是重复的情况 阅读全文
摘要:
https://blog.csdn.net/pistolove/article/details/46868017 阅读全文
摘要:
数字的末尾为0实际上就是乘以了10,20、30、40其实本质上都是10,只不过是10的倍数。10只能通过2*5来获得,但是2的个数众多,用作判断不准确。 以20的阶乘为例子,造成末尾为0的数字其实就是5、10、15、20。 多次循环的n,其实是使用了多个5的数字,比如25,125等等。 n/5代表的 阅读全文
摘要:
用异或解决 用https://www.cnblogs.com/grandyang/p/4756677.html的第二种方法 class Solution { public: int missingNumber(vector<int>& nums) { int length = nums.size() 阅读全文
摘要:
注意k可能大于length 阅读全文
摘要:
118. Pascal's Triangle 第一种解法:比较麻烦 https://leetcode.com/problems/pascals-triangle/discuss/166279/cpp-beats-1002018.9.3(with-annotation) 第二种解法: http://w 阅读全文