随笔分类 -  LeetCode提高班第4期——Google面试题专题(2)

摘要:1 class Solution 2 { 3 public: 4 double mincostToHireWorkers(vector<int>& quality, vector<int>& wage, int K) 5 { 6 vector<pair<double,int>> vec; 7 for 阅读全文
posted @ 2020-04-30 10:36 Jinxiaobo0509 阅读(225) 评论(0) 推荐(0)
摘要:1 class Solution 2 { 3 void calc(stack<char>& op,stack<int>& num) 4 { 5 int y = num.top(); 6 num.pop(); 7 int x = num.top(); 8 num.pop(); 9 if(op.top( 阅读全文
posted @ 2020-04-29 22:41 Jinxiaobo0509 阅读(205) 评论(0) 推荐(0)
摘要:1 class Solution 2 { 3 public: 4 vector<vector<int>> insert(vector<vector<int>>& nums, vector<int>& newInterval) 5 { 6 nums.push_back(newInterval); 7 阅读全文
posted @ 2020-04-29 21:55 Jinxiaobo0509 阅读(148) 评论(0) 推荐(0)
摘要:1 class Solution 2 { 3 public: 4 int numSubarraysWithSum(vector<int>& nums, int k) 5 { 6 unordered_map<int,int> hash;// 和+次数 7 hash[0] = 1; 8 9 int re 阅读全文
posted @ 2020-04-29 21:13 Jinxiaobo0509 阅读(157) 评论(0) 推荐(0)
摘要:1 class Solution 2 { 3 public: 4 int projectionArea(vector<vector<int>>& grid) 5 { 6 int m = grid.size(),n = grid[0].size(); 7 int res = 0; 8 for(int 阅读全文
posted @ 2020-04-29 18:09 Jinxiaobo0509 阅读(132) 评论(0) 推荐(0)
摘要:1 class Solution 2 { 3 public: 4 bool isPowerOfThree(int n) 5 { 6 return n > 0 && 1162261467 % n == 0; 7 } 8 }; 阅读全文
posted @ 2020-04-21 17:25 Jinxiaobo0509 阅读(78) 评论(0) 推荐(0)
摘要:1 class Solution 2 { 3 public: 4 int kthSmallest(TreeNode* root, int k) 5 { 6 stack<TreeNode*> s; 7 TreeNode *cur = root; 8 while(!s.empty() || cur) 9 阅读全文
posted @ 2020-04-12 13:58 Jinxiaobo0509 阅读(183) 评论(0) 推荐(0)
摘要:1 //简单题 2 class Solution 3 { 4 public: 5 vector<string> summaryRanges(vector<int>& nums) 6 { 7 vector<string> res; 8 if(nums.empty()) return res; 9 ve 阅读全文
posted @ 2020-04-12 11:59 Jinxiaobo0509 阅读(154) 评论(0) 推荐(0)
摘要:1 class Solution 2 { 3 public: 4 bool wordBreak(string s, vector<string>& wordDict) 5 { 6 vector<bool> dp(s.size()+1, false); 7 unordered_set<string> 阅读全文
posted @ 2020-04-02 17:54 Jinxiaobo0509 阅读(156) 评论(0) 推荐(0)
摘要:1 class Solution 2 { 3 public: 4 vector<int> plusOne(vector<int>& digits) 5 { 6 int n = digits.size(); 7 int C = 1;//进位 8 for(int i = n - 1;i >= 0;i - 阅读全文
posted @ 2020-03-20 15:15 Jinxiaobo0509 阅读(135) 评论(0) 推荐(0)