Commit use append
This commit is contained in:
parent
48d8a7bf72
commit
5137559993
Binary file not shown.
|
@ -61,12 +61,9 @@ public class RecursiveExercise {
|
||||||
if(ht==null)return null;
|
if(ht==null)return null;
|
||||||
if(n==0)return ht;
|
if(n==0)return ht;
|
||||||
int temp = ht[0];
|
int temp = ht[0];
|
||||||
ht = insertLast(temp,MyArrayUtil.tail(ht));
|
ht = reverse(MyArrayUtil.addAsFirst(temp, reverse(MyArrayUtil.tail(ht))));
|
||||||
return shift(ht,n-1);
|
return shift(ht,n-1);
|
||||||
}
|
}
|
||||||
public static int[] insertLast(int val,int[] ia) throws Exception{
|
|
||||||
return reverse(MyArrayUtil.addAsFirst(val, reverse(ia)));
|
|
||||||
}
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
// test append, when appending empty array with {1,2,3}
|
// test append, when appending empty array with {1,2,3}
|
||||||
int[] a = null;
|
int[] a = null;
|
||||||
|
|
Loading…
Reference in New Issue