摘要:
把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) { 阅读全文
摘要:
https://www.cnblogs.com/grandyang/p/5144918.html 1. class Solution { public: int nthSuperUglyNumber(int n, vector<int>& primes) { vector<int> res(1,1) 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
class Solution { public: int addDigits(int num) { while(num>=10) { int sum=0; while(num) { sum+=num%10; num/=10; } num=sum; } return num; } }; 阅读全文
摘要:
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的倍数 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文