Skip to content
Snippets Groups Projects
Commit 982a766d authored by Adam Blank's avatar Adam Blank
Browse files

Fixes minor bug in subsetsum implementation

parent 2d2f5d66
No related branches found
No related tags found
No related merge requests found
package cse332.backtracking;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
......@@ -14,8 +14,7 @@ public class SubsetSum {
@SuppressWarnings("unchecked")
private static <E> E[] rest(E[] list) {
E[] rest = (E[]) Array.newInstance(list.getClass().getComponentType(), list.length - 1);
return rest;
return Arrays.copyOfRange(list, 1, list.length);
}
......@@ -86,4 +85,4 @@ public class SubsetSum {
return output;
}
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment