Skip to content

Commit afecf62

Browse files
authored
Create yeonguchoe.cs
1 parent cf44d0f commit afecf62

File tree

1 file changed

+25
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)