8000 Create sourcema.md by MMzhe · Pull Request #788 · gzc426/leetcode · GitHub
[go: up one dir, main page]

Skip to content

Create sourcema.md #788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Create sourcema.md
  • Loading branch information
MMzhe authored Mar 30, 2019
commit 87b6fd39853512438aedcfa0573c906a0c6f9f7d
25 changes: 25 additions & 0 deletions 2019.02.10-leetcode300/sourcema.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# leetcode 300
class Solution {
public int lengthOfLIS(int[] nums) {
if(nums==null||nums.length==0){
return 0;
}
int n=nums.length;
int[] dp=new int[n];
for(int i=0;i<n;i++){
dp[i]=1;
for(int j=0;j<i;j++){
if(nums[i]>nums[j]){
dp[i]=Math.max(dp[i],dp[j]+1);
}
}
}
int res=0;
for(int i=0;i<n;i++){
if(dp[i]>res){
res=dp[i];
}
}
return res;
}
}
0