In: Computer Science
In Java:
public static int[] copy(int[] arr, int n) { int[] result = new int[n]; for (int i = 0; i < n; i++) { result[i] = arr[i]; } return result; } public static int[] slice(int[] arr, int i, int j) { int[] result = new int[j-i+1]; for (int k = 0; k < result.length; k++) { result[k] = arr[i+k]; } return result; }