摘要: 1 //这道题没有思路,借鉴别人的代码 2 3 4 //1、使用递归。 5 //2、每次可以放置左括号的条件是当前左括号的数目不超过 nn。 6 //3、每次可以放置右括号的条件是当前右括号的数目不超过左括号的数目。 7 class Solution 8 { 9 vector<string> res 阅读全文
posted @ 2020-03-15 18:38 Jinxiaobo0509 阅读(135) 评论(0) 推荐(0)
摘要: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; 阅读全文
posted @ 2020-03-15 18:36 Jinxiaobo0509 阅读(97) 评论(0) 推荐(0)
摘要: 1 //思路很清晰,直接用stack 2 class Solution 3 { 4 unordered_map<char,char> hash = {{'(',')'},{'[',']'},{'{','}'}}; 5 public: 6 bool isValid(string s) 7 { 8 st 阅读全文
posted @ 2020-03-15 18:35 Jinxiaobo0509 阅读(96) 评论(0) 推荐(0)
摘要: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; 阅读全文
posted @ 2020-03-15 18:34 Jinxiaobo0509 阅读(100) 评论(0) 推荐(0)
摘要: 1 //跟三数之和思想一样的,只不过多一层循环 2 class Solution 3 { 4 public: 5 vector<vector<int>> fourSum(vector<int>& nums, int target) 6 { 7 vector<vector<int>> res; 8 i 阅读全文
posted @ 2020-03-15 18:33 Jinxiaobo0509 阅读(116) 评论(0) 推荐(0)
摘要: 1 //DFS问题一直很难 2 class Solution 3 { 4 void dfs(string digits,vector<vector<char>>& d,vector<string> &res,int cur,string& temp) 5 { 6 if(cur == digits.s 阅读全文
posted @ 2020-03-15 18:32 Jinxiaobo0509 阅读(144) 评论(0) 推荐(0)
摘要: 1 //搞清楚各个变量的含义 2 //***忘记对数组进行排序,以至于一直卡在这里*** 3 class Solution 4 { 5 public: 6 int threeSumClosest(vector<int>& nums, int target) 7 { 8 int n = nums.si 阅读全文
posted @ 2020-03-15 18:31 Jinxiaobo0509 阅读(141) 评论(0) 推荐(0)
摘要: 1 // 312/313 始终会出现一种情况——>全0 2 3 // 后来引进了双指针算法 4 class Solution 5 { 6 public: 7 vector<vector<int>> threeSum(vector<int>& nums) 8 { 9 vector<vector<int 阅读全文
posted @ 2020-03-15 18:29 Jinxiaobo0509 阅读(106) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 string longestCommonPrefix(vector<string>& strs) 5 { 6 string res; 7 if(strs.empty()) return res; 8 int min_length = 阅读全文
posted @ 2020-03-15 18:26 Jinxiaobo0509 阅读(129) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 private: 4 unordered_map<string,int> hash = {{"I",1},{"IV",4},{"V",5},{"IX",9},{"X",10}, 5 {"XL",40},{"L",50},{"XC",90},{"C",10 阅读全文
posted @ 2020-03-15 18:25 Jinxiaobo0509 阅读(109) 评论(0) 推荐(0)