摘要: 把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 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(82) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(76) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(106) 评论(0) 推荐(0) 编辑