Skip to content

Commit 43fa357

Browse files
committed
add a test case forLIS backtrack
1 parent 109f62e commit 43fa357

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

IntArrayOps/src/IntArrayOps.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static void main(String[] args) {
1414

1515
System.out.println(Arrays.toString(a));
1616

17-
int[] a1 = new int[]{16, 7, 8, 9, 10, 13, 0, 1, 2, 0, 9, 13, 14};
17+
int[] a1 = new int[]{16, 18, 7, 8, 9, 10, 13, 0, 1, 2, 0, 9, 13, 14};
1818
System.out.println(Arrays.toString(a1));
1919
ArrayList<Integer> lis = LIS(a1);
2020
System.out.println("LIS: " + lis.toString());
@@ -346,7 +346,7 @@ public static ArrayList<Integer> LIS(int[] a) {
346346

347347
int index = trackLargestIndex.getLast();
348348
ArrayList<Integer> lis = new ArrayList<Integer>();
349-
while(index != 0) {
349+
for (int n = 0; n < trackLargestIndex.size(); ++n) {
350350
lis.add(0, a[index]);
351351
index = path[index];
352352
}

0 commit comments

Comments
 (0)