| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 
 | public class Test7 {
 public static void main(String[] args) {
 int[] a = {0, 1, 6, 2, 3, 7, 5};
 maxIncreaseList(a);
 int[] b = {0, 10, 9, 2, 5, 3, 7, 101, 18};
 maxIncreaseList(b);
 }
 
 private static void maxIncreaseList(int[] a) {
 int[] dp = new int[a.length];
 dp[1] = 1;
 
 for (int i = 2; i <= a.length - 1; i++) {
 dp[i] = 1;
 for (int j = 1; j < i; j++) {
 if (a[i] > a[j]) {
 dp[i] = Math.max(dp[j] + 1, dp[i]);
 }
 }
 }
 int max = 1;
 for (int i = 1; i <= a.length - 1; i++) {
 if (dp[i] > max) {
 max = dp[i];
 }
 }
 System.out.println(max);
 }
 }
 
 |