摘要: 1 class MyQueue 2 { 3 stack<int> s1,s2; 4 public: 5 MyQueue() {} 6 7 void push(int x) 8 { 9 s1.push(x); 10 } 11 12 int pop() 13 { 14 while(!s1.empty() 阅读全文
posted @ 2020-04-11 23:17 Jinxiaobo0509 阅读(116) 评论(0) 推荐(0)
摘要: 1 class MyStack 2 { 3 queue<int> q1;//数据队列 4 queue<int> q2;//临时队列 5 public: 6 MyStack() {} 7 8 void push(int x) 9 { 10 q1.push(x); 11 } 12 13 int pop( 阅读全文
posted @ 2020-04-11 22:36 Jinxiaobo0509 阅读(93) 评论(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-11 19:49 Jinxiaobo0509 阅读(105) 评论(0) 推荐(0)
摘要: 1 //从四个方向比较,只要任意一个方向不满足,就不重叠 2 class Solution 3 { 4 public: 5 int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) 6 { 7 long long 阅读全文
posted @ 2020-04-11 18:17 Jinxiaobo0509 阅读(312) 评论(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-11 17:32 Jinxiaobo0509 阅读(150) 评论(0) 推荐(0)
摘要: 1 //dp(i, j)=min(dp(i−1, j), dp(i−1, j−1), dp(i, j−1))+1 2 class Solution 3 { 4 public: 5 int maximalSquare(vector<vector<char>>& matrix) 6 { 7 if(mat 阅读全文
posted @ 2020-04-11 16:29 Jinxiaobo0509 阅读(134) 评论(0) 推荐(0)
摘要: 1 //用multimap就可以解决 2 class Solution 3 { 4 public: 5 bool containsNearbyAlmostDuplicate(vector<int>& nums, int k, int t) 6 { 7 if(nums.empty()) return 阅读全文
posted @ 2020-04-11 14:09 Jinxiaobo0509 阅读(138) 评论(0) 推荐(0)