isInterleave

#include #include #include #include using namespace std; bool isInterleave(string& s1,string& s2,string& s3) { vector>f(s1.size...

2015-11-23 00:12:53

阅读数:193

评论数:0

maxProfit

#include #include #include using namespace std; int maxProfit(vector&prices) { const int n=prices.size(); if(n return 0; vectorf(n,0); ...

2015-11-22 21:59:04

阅读数:358

评论数:0

maximalRectangle

#include #include #include using namespace std; int maximalRectangle(vector>&matrix) { const int m=matrix.size(); const int n=matrix[0]...

2015-11-22 17:00:35

阅读数:179

评论数:0

minCut

#include #include #include #include using namespace std; int minCut(string s) { const int n = s.size(); vectorf(n+1); bool p[100][100]; fil...

2015-11-21 15:35:34

阅读数:173

评论数:0

maxSubArray

#include #include using namespace std; int maxSubArray(int A[],int n) { int result=INT_MIN,f=0; for(int i=0;i { f=max(f+A[i],A[i]); result=m...

2015-11-20 23:02:07

阅读数:169

评论数:0

triangle

#include #include #include using namespace std; int minimumTotal(vector>&triangle) { for(int i=triangle.size()-2;i>=0;--i) { for(in...

2015-11-20 22:23:02

阅读数:160

评论数:0

container with most water

#include #include #include using namespace std; int maxArea(vector&height) { int left = 0; int right = height.size() - 1; int result = 0;...

2015-11-11 16:11:46

阅读数:151

评论数:0

longestSubstring

#include #include #include #include using namespace std; int lengthOfLongestSubsring(string s) { const int ascII = 26; int last[ascII] = { -1...

2015-11-10 22:39:41

阅读数:157

评论数:0

canJump&&jumpII

#include #include #include using namespace std; bool canJump(int a[], int n) { int reach = 1; for (int i = 0;i { reach = max(reach, i + 1 + a[i]); }...

2015-11-10 16:20:23

阅读数:154

评论数:0

二分法pow和sqrt

#include using namespace std; int sqrt(int x) { if(x return 1; int left=1; int right=x/2; //int last_mid; while(left { int mid=left+(right...

2015-11-06 22:37:09

阅读数:253

评论数:0

wordSearch

#include #include #include using namespace std; bool dfs(vector>&board,string&word,int index,int x,int y,vector>&visited) { i...

2015-11-06 17:05:45

阅读数:143

评论数:0

generateParenthesses

#include #include #include using namespace std; void generate(int n,string s,int l,int r,vector&result) { if(l==n) { s.append(n-r,')'); result.pu...

2015-11-05 20:12:29

阅读数:148

评论数:0

combinationSum&&combinationSumII

#include #include #include #include using namespace std; void dfs(vector&nums,int gap,int start,vector&intermediate,vector>&result) { ...

2015-11-05 13:29:24

阅读数:154

评论数:0

storeIpAddresses

#include #include #include using namespace std; void dfs(string s,size_t start,size_t step,string&ip,vector& result) { if(start==s.size...

2015-11-05 12:47:24

阅读数:167

评论数:0

wordLadder

#include #include #include #include #include using namespace std; int ladderLength(const string& start,const string& end,const unordered_set&...

2015-09-20 20:49:34

阅读数:204

评论数:0

next_permutation

#include #include #include using namespace std; int main() { vectornum; num.push_back(1); num.push_back(2); num.push_back(3); do { for(auto i:num) co...

2015-09-19 14:05:28

阅读数:154

评论数:0

增量法subsets

#include #include #include #include using namespace std; vector>subsets(vector&s) { sort(s.begin(),s.end()); vector>result(1); int...

2015-09-17 00:09:06

阅读数:197

评论数:0

searchRange

#include #include #include using namespace std; vector searchRange(int A[],int n,int target) { int l=distance(A,lower_bound(A,A+n,target)); in...

2015-09-13 22:52:12

阅读数:80

评论数:0

findFirstMissingPositive

void bucket_sort(int A[],int n) { for(size_t i=0;i { while(A[i]!=i+1) { if(A[i]n||A[i]==A[A[i]-1]) break; swap(A[i],A[A[i]-1]); } } } int...

2015-09-13 20:43:22

阅读数:129

评论数:0

maxPathSum

int maxPathSum(TreeNode* root) { int maxSum=INT_MIN; dfs(root,maxSum); return maxSum; } int dfs(TreeNode* root,int&maxSum) { if(root==nul...

2015-09-09 22:02:59

阅读数:160

评论数:0

提示
确定要删除当前文章?
取消 删除
关闭
关闭