上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 38 下一页
摘要: 给你一个数组 [2,1,2,4,3],你返回数组 [4,2,4,-1,-1]。 解释:第一个 2 后面比 2 大的数是 4; 1 后面比 1 大的数是 2;第二个 2 后面比 2 大的数是 4; 4 后面没有比 4 大的数,填 -1;3 后面没有比 3 大的数,填 -1。 1、右边第一个数比它大,从 阅读全文
posted @ 2020-04-18 21:30 Jinxiaobo0509 阅读(118) 评论(0) 推荐(0)
摘要: 1 bool cmp(vector<int>& a,vector<int>& b) 2 { 3 //第一个数从小到大排列 如果第一个数相等,则第二个数从小到大排列 4 return a[0] < b[0] || ((a[0] == b[0]) && (a[1] < b[1])); 5 } 6 7 c 阅读全文
posted @ 2020-04-18 17:11 Jinxiaobo0509 阅读(120) 评论(0) 推荐(0)
摘要: 1 bool cmp(vector<int>& a,vector<int>& b) 2 { 3 //第一个数从大到小排列 如果第一个数相等,则第二个数从小到大排列 4 return a[0] > b[0] || ((a[0] == b[0]) && (a[1] < b[1])); 5 } 6 7 c 阅读全文
posted @ 2020-04-18 16:47 Jinxiaobo0509 阅读(115) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 int wiggleMaxLength(vector<int>& nums) 5 { 6 //删除相邻且相同的元素 7 nums.erase(unique(nums.begin(),nums.end()),nums.end()); 8 阅读全文
posted @ 2020-04-18 16:03 Jinxiaobo0509 阅读(94) 评论(0) 推荐(0)
摘要: 1 //BFS + 贪心 2 //维护一个区间[l,r],在这里面可以找到能够跳到最大位置,step++,同时更新l,r 3 class Solution 4 { 5 public: 6 int jump(vector<int>& nums) 7 { 8 if(nums.size() < 2) re 阅读全文
posted @ 2020-04-18 14:57 Jinxiaobo0509 阅读(90) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 int findContentChildren(vector<int>& g, vector<int>& s) 5 { 6 sort(g.rbegin(),g.rend()); 7 sort(s.rbegin(),s.rend()); 阅读全文
posted @ 2020-04-18 11:24 Jinxiaobo0509 阅读(69) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 bool isSubsequence(string s, string t) 5 { 6 int n = s.size(); 7 int i = 0; 8 for(int j = 0;j < t.size();j ++) 9 { 10 阅读全文
posted @ 2020-04-18 11:06 Jinxiaobo0509 阅读(105) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 bool lemonadeChange(vector<int>& bills) 5 { 6 unordered_map<int,int> hash; 7 for(auto a : bills) 8 { 9 if(a == 5) has 阅读全文
posted @ 2020-04-18 10:37 Jinxiaobo0509 阅读(147) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 int temp; 4 public: 5 vector<vector<int>> floodFill(vector<vector<int>>& image, int sr, int sc, int newColor) 6 { 7 int m = ima 阅读全文
posted @ 2020-04-17 22:54 Jinxiaobo0509 阅读(196) 评论(0) 推荐(0)
摘要: 1 struct Node 2 { 3 Node* next[2] = {nullptr}; 4 }; 5 6 class Solution 7 { 8 public: 9 void insert(int num, Node* root) 10 { 11 for (int i = 30; i >= 阅读全文
posted @ 2020-04-17 21:39 Jinxiaobo0509 阅读(197) 评论(0) 推荐(0)
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 38 下一页