随笔分类 -  leetcode

摘要:问题描述 解决方案 //按照组合的方法,求解 class Solution { public: int countNumbersWithUniqueDigits(int n) { if(n==0) return 1; int count=10; for(int i=2;i 阅读全文
posted @ 2016-08-26 14:46 弦断 阅读(240) 评论(0) 推荐(0)
摘要:问题描述 解决方案 阅读全文
posted @ 2016-08-26 13:25 弦断 阅读(169) 评论(0) 推荐(0)
摘要:问题描述 解决方案 我的解决方法 class Solution { public: int climbStairs(int n) { int a=1,b=1; for(int i=1;i 阅读全文
posted @ 2016-08-26 11:16 弦断 阅读(205) 评论(0) 推荐(0)
摘要:问题描述 解决方案 阅读全文
posted @ 2016-08-25 00:02 弦断 阅读(175) 评论(0) 推荐(0)
摘要:问题描述 解决方案 我的方法 别人的 阅读全文
posted @ 2016-08-24 23:25 弦断 阅读(214) 评论(0) 推荐(0)
摘要:问题描述 解决方案 class Solution { public: int maxProfit(vector& prices) { int ret =0; for(int i=1;i 阅读全文
posted @ 2016-08-24 22:57 弦断 阅读(199) 评论(0) 推荐(0)
摘要:问题描述 解决方案 class Solution { public: bool containsNearbyDuplicate(vector& nums, int k) { unordered_map mii; for(int i=0;i 阅读全文
posted @ 2016-08-24 07:49 弦断 阅读(103) 评论(0) 推荐(0)
摘要:问题描述 解决方案 阅读全文
posted @ 2016-08-23 22:08 弦断 阅读(107) 评论(0) 推荐(0)
摘要:问题描述 解决方案 cpp class Solution { public: int firstUniqChar(string s) { unordered_map mci; for(int i=0;i 阅读全文
posted @ 2016-08-23 22:04 弦断 阅读(128) 评论(0) 推荐(0)
摘要:问题描述 解决方案 渣方法解决的 阅读全文
posted @ 2016-08-23 21:52 弦断 阅读(93) 评论(0) 推荐(0)
摘要:问题描述 解决方案 阅读全文
posted @ 2016-08-23 20:35 弦断 阅读(110) 评论(0) 推荐(0)
摘要:问题描述 解决方案 下面两种方法的原理是相同的 cpp // class Solution { // public: // void rotate(vector& nums, int k) { // k%=nums.size(); // reverse(nums.begin(),nums.end() 阅读全文
posted @ 2016-08-23 17:34 弦断 阅读(101) 评论(0) 推荐(0)
摘要:问题描述 解决方案 cpp class Solution { public: //考虑溢出情况 int myAtoi(string str) { long long int lli=atoll(str.c_str()); if(lli 0&&lli INT_MAX) lli=INT_MAX; if( 阅读全文
posted @ 2016-08-22 23:50 弦断 阅读(114) 评论(0) 推荐(0)
摘要:问题描述 解决方案 阅读全文
posted @ 2016-08-22 23:15 弦断 阅读(123) 评论(0) 推荐(0)
摘要:问题描述 解决方案 阅读全文
posted @ 2016-08-22 14:16 弦断 阅读(106) 评论(0) 推荐(0)
摘要:问题描述 解决方案 非递归方式 递归方式 阅读全文
posted @ 2016-08-22 14:06 弦断 阅读(112) 评论(0) 推荐(0)
摘要:问题描述 解决方案 cpp class Solution { public: bool isPowerOfThree(int n) { if(n 阅读全文
posted @ 2016-08-22 10:21 弦断 阅读(126) 评论(0) 推荐(0)
摘要:问题描述 解决方案 位运算 bitset 阅读全文
posted @ 2016-08-22 10:02 弦断 阅读(111) 评论(0) 推荐(0)
摘要:问题描述 解决方案 cpp class Solution { public: // int majorityElement(vector& nums) { // sort(nums.begin(),nums.end()); // return nums[nums.size()/2]; // } in 阅读全文
posted @ 2016-08-21 11:55 弦断 阅读(95) 评论(0) 推荐(0)
摘要:问题描述 解决方案 阅读全文
posted @ 2016-08-21 11:31 弦断 阅读(106) 评论(0) 推荐(0)