摘要: class Solution { public: int longestValidParentheses(string s) { if(s.size()<2) return 0; int n=s.size(); int res=0; vector<int> dp(n,0); //dp[i]表示以nu 阅读全文
posted @ 2020-03-07 18:22 7aughing 阅读(132) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int search(vector<int>& nums, int target) { if(nums.size()==0) return -1; int left=0,right=nums.size()-1; while(left+1<right) 阅读全文
posted @ 2020-03-07 18:04 7aughing 阅读(129) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: void nextPermutation(vector<int>& nums) { if(nums.size()<=1) return; int i=nums.size()-2; while(i>=0 && nums[i]>=nums[i+1]){ 阅读全文
posted @ 2020-03-07 17:44 7aughing 阅读(108) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: void dfs(int n, int left, int right, string path, vector<string>& res){ if(right==n){ res.push_back(path); return; } if(left< 阅读全文
posted @ 2020-03-07 17:24 7aughing 阅读(160) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: bool isValid(string s) { if(s.size()==0) return true; map<char,char> hash={ {')','('}, {'}','{'}, {']','['} }; stack<int> st; 阅读全文
posted @ 2020-03-07 17:16 7aughing 阅读(113) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solu 阅读全文
posted @ 2020-03-07 17:09 7aughing 阅读(82) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: void dfs(string digits, int idx, map<char,string> hash, string path, vector<string>& res){ if(idx==digits.size()){ res.push_b 阅读全文
posted @ 2020-03-07 17:00 7aughing 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 题目:三数之和 题目描述: 给你一个整数数组 nums ,判断是否存在三元组 [nums[i], nums[j], nums[k]] 满足 i != j、i != k 且 j != k ,同时还满足 nums[i] + nums[j] + nums[k] == 0 。请 你返回所有和为 0 且不重复 阅读全文
posted @ 2020-03-07 16:48 7aughing 阅读(147) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int maxArea(vector<int>& height) { if(height.size()==0) return 0; int left=0,right=height.size()-1; int res=INT_MIN; while(le 阅读全文
posted @ 2020-03-07 16:35 7aughing 阅读(77) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: bool isMatch(string s, string p) { int m=s.size(),n=p.size(); vector<vector<bool>> dp(m+1,vector<bool>(n+1,false)); dp[0][0]= 阅读全文
posted @ 2020-03-07 16:16 7aughing 阅读(200) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: string longestPalindrome(string s) { if(s.size()==0 || s.size()==1) return s; int n=s.size(); vector<vector<bool>> isPail(n,v 阅读全文
posted @ 2020-03-07 15:56 7aughing 阅读(117) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) { int len1=nums1.size(),len2=nums2.size(); if(len1>len2 阅读全文
posted @ 2020-03-07 15:41 7aughing 阅读(318) 评论(0) 推荐(0) 编辑