Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7665b70

Browse files
Add Solution.java to problems 0300
1 parent 6e78513 commit 7665b70

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
public int lengthOfLIS(int[] nums) {
3+
int i, j, max = 0, n = nums.length;
4+
int[] dp = new int[n];
5+
6+
for (i = 0; i < n; i++) {
7+
dp[i] = 1;
8+
}
9+
for (i = 0; i < n; i++) {
10+
for (j = 0; j < i; j++) {
11+
if (nums[j] < nums[i] && dp[i] < dp[j] + 1) {
12+
dp[i] = dp[j] + 1;
13+
}
14+
}
15+
max = Math.max(max, dp[i]);
16+
}
17+
return max;
18+
}
19+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /