Skip to content

Commit a9eea24

Browse files
committed
not yet
1 parent 900fe82 commit a9eea24

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

141 Bytes
Binary file not shown.

src/Class27/LongestAscendingSubsequence.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
package Class27;
2-
2+
/*
3+
* Given an array A[0]...A[n-1] of integers, find out the length of the longest
4+
* ascending subsequence.
5+
*
6+
* Assumptions
7+
* A is not null
8+
*
9+
* Examples
10+
* Input: A = {5, 2, 6, 3, 4, 7, 5}
11+
* Output: 4
12+
* Because [2, 3, 4, 5] is the longest ascending subsequence.
13+
*/
314
public class LongestAscendingSubsequence {
15+
// definition: M[i] represents the longest ascending sub-sequence at A[i]
16+
// induction rule: M[i] = max(M[i], M[k]) when A[i] > A[k]
17+
public int longest(int[] array) {
18+
if (array.length <= 1) {
19+
return array.length;
20+
}
21+
return 0;
22+
}
423

524
public static void main(String[] args) {
625
// TODO Auto-generated method stub

0 commit comments

Comments
 (0)