上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 38 下一页
摘要: 1 class Solution 2 { 3 public: 4 int hIndex(vector<int>& nums) 5 { 6 sort(nums.begin(),nums.end()); 7 int l = 0,r = nums.size(); 8 while(l < r) 9 { 10 阅读全文
posted @ 2020-04-15 10:35 Jinxiaobo0509 阅读(94) 评论(0) 推荐(0)
摘要: 1 //[3,0,1] + [0,1,2,3] = [0,0,1,1,2,3,3] ——> 求异或 2 class Solution 3 { 4 public: 5 int missingNumber(vector<int>& nums) 6 { 7 int n = nums.size(); 8 i 阅读全文
posted @ 2020-04-15 10:26 Jinxiaobo0509 阅读(139) 评论(0) 推荐(0)
摘要: 1 //动态方程dp[i]=min(dp[p_2]*2,dp[p_3]*3,dp[p_5]*5) 2 class Solution 3 { 4 public: 5 int nthUglyNumber(int n) 6 { 7 vector<int> dp(n); 8 dp[0] = 1; 9 int 阅读全文
posted @ 2020-04-14 19:30 Jinxiaobo0509 阅读(86) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 bool isUgly(int num) 5 { 6 if (num == 0) return false; 7 while (num % 2 == 0) num /= 2; 8 while (num % 3 == 0) num /= 阅读全文
posted @ 2020-04-14 19:27 Jinxiaobo0509 阅读(95) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 vector<int> singleNumber(vector<int>& nums) 5 { 6 int diff = 0; 7 vector<int> res(2,0); 8 for (int num : nums) diff ^ 阅读全文
posted @ 2020-04-12 23:10 Jinxiaobo0509 阅读(106) 评论(0) 推荐(0)
摘要: 1 //很简单 2 class Solution 3 { 4 public: 5 int addDigits(int num) 6 { 7 while(num > 9) 8 { 9 int temp = 0; 10 while(num) 11 { 12 temp += num % 10; 13 nu 阅读全文
posted @ 2020-04-12 22:38 Jinxiaobo0509 阅读(117) 评论(0) 推荐(0)
摘要: 1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), 阅读全文
posted @ 2020-04-12 22:31 Jinxiaobo0509 阅读(149) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 bool isAnagram(string s, string t) 5 { 6 unordered_map<char,int> hash_s,hash_t; 7 for(auto a : s) hash_s[a] ++; 8 for 阅读全文
posted @ 2020-04-12 20:42 Jinxiaobo0509 阅读(125) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 vector<int> diffWaysToCompute(string input) 5 { 6 vector<int> res; 7 for(int i=0; i<input.size(); i++) 8 { 9 if(input 阅读全文
posted @ 2020-04-12 20:38 Jinxiaobo0509 阅读(143) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 bool searchMatrix(vector<vector<int>>& matrix, int target) 5 { 6 if(matrix.empty() || matrix[0].empty()) return false 阅读全文
posted @ 2020-04-12 18:46 Jinxiaobo0509 阅读(121) 评论(0) 推荐(0)
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 38 下一页