随笔分类 - 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
阅读全文
摘要: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(
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:1 class Solution 2 { 3 public: 4 bool isPowerOfThree(int n) 5 { 6 return n > 0 && 1162261467 % n == 0; 7 } 8 };
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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>
阅读全文
摘要: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 -
阅读全文

浙公网安备 33010602011771号