会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
qiujiejie
博客园
首页
新随笔
联系
订阅
管理
2020年7月3日
leetcode 1. 两数之和
摘要: 把top 100重新刷一遍 class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { unordered_map<int,int> um; for(int i=0;i<nums.size();++i) {
阅读全文
posted @ 2020-07-03 22:00 qiujiejie
阅读(89)
评论(0)
推荐(0)
2020年6月30日
leetcode 313. Super Ugly Number
摘要: https://www.cnblogs.com/grandyang/p/5144918.html 1. class Solution { public: int nthSuperUglyNumber(int n, vector<int>& primes) { vector<int> res(1,1)
阅读全文
posted @ 2020-06-30 10:18 qiujiejie
阅读(136)
评论(0)
推荐(0)
2020年6月29日
leetcode 268. Missing Number
摘要: 1. class Solution { public: int missingNumber(vector<int>& nums) { sort(nums.begin(),nums.end()); for(int i=0;i<nums.size();++i) { if(nums[i]!=i) retu
阅读全文
posted @ 2020-06-29 10:35 qiujiejie
阅读(142)
评论(0)
推荐(0)
2020年6月28日
leetcode 263. Ugly Number
摘要: https://www.cnblogs.com/grandyang/p/4741934.html class Solution { public: bool isUgly(int num) { if(num<=0) return false; while(num%2==0) num/=2; whil
阅读全文
posted @ 2020-06-28 09:47 qiujiejie
阅读(112)
评论(0)
推荐(0)
leetcode 258. Add Digits
摘要: class Solution { public: int addDigits(int num) { while(num>=10) { int sum=0; while(num) { sum+=num%10; num/=10; } num=sum; } return num; } };
阅读全文
posted @ 2020-06-28 09:41 qiujiejie
阅读(137)
评论(0)
推荐(0)
2020年6月27日
leetcode 231. Power of Two
摘要: 1. class Solution { public: bool isPowerOfTwo(int n) { if(n<=0) return false; while(n!=1) { if(n%2) return false; n/=2; } return true; } }; 2. 如果是2的倍数
阅读全文
posted @ 2020-06-27 18:13 qiujiejie
阅读(100)
评论(0)
推荐(0)
leetcode 224. Basic Calculator
摘要: https://www.cnblogs.com/grandyang/p/4570699.html class Solution { public: int calculate(string s) { int sign=1,res=0,n=s.size(); stack<int> sta; for(i
阅读全文
posted @ 2020-06-27 17:54 qiujiejie
阅读(84)
评论(0)
推荐(0)
2020年6月26日
leetcode 223 Rectangle Area
摘要: https://leetcode.com/problems/rectangle-area/discuss/705462/C-36-ms-100-O(1)-15.4-mb-100-O(1) class Solution { public: int computeArea(int A, int B, i
阅读全文
posted @ 2020-06-26 08:44 qiujiejie
阅读(79)
评论(0)
推荐(0)
2020年6月24日
leetcode 451 Sort Characters By Frequency
摘要: 1. class Solution { public: string frequencySort(string s) { map<char,int> m; for(auto& c:s) { ++m[c]; } string str;char c; while((c=get_max(m))) { if
阅读全文
posted @ 2020-06-24 23:42 qiujiejie
阅读(105)
评论(0)
推荐(0)
2020年5月8日
leetcode 264 Ugly Number II
摘要: https://leetcode.com/problems/ugly-number-ii/discuss/591634/C%2B%2B-easy-O(n)-DP 一个丑数乘以2/3/5仍然是一个丑数;t2、t3、t5记录当前应该乘以2、3、5的数字的位置,选择乘积最小的一个。 class Solut
阅读全文
posted @ 2020-05-08 09:59 qiujiejie
阅读(107)
评论(0)
推荐(0)
下一页
公告