Skip to content

Commit e051f73

Browse files
YeonguChoeobzva
andauthored
Update longest-increasing-subsequence/yeonguchoe.cs
Co-authored-by: Dongyeong Chon <[email protected]>
1 parent 4517980 commit e051f73

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

longest-increasing-subsequence/yeonguchoe.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@ public int LengthOfLIS(int[] nums) {
77
dp[i] = 1;
88
}
99

10+
int maxLength = 1;
1011
for (int i = 1; i < nums.Length; i++) {
1112
for (int j = 0; j < i; j++) {
1213
if (nums[j] < nums[i]) {
1314
dp[i] = Math.Max(dp[i], dp[j] + 1);
1415
}
1516
}
16-
}
17-
18-
int maxLength = 1;
19-
foreach (int length in dp) {
20-
maxLength = Math.Max(maxLength, length);
17+
maxLength = Math.max(maxLength, dp[i]);
2118
}
2219

2320
return maxLength;

0 commit comments

Comments
 (0)