Browse Source

RemoveLast

master
Florentin Koepff 3 years ago
parent
commit
44afb413c1
  1. 14
      ArrayManipulation.java

14
ArrayManipulation.java

@ -27,6 +27,19 @@ public class ArrayManipulation {
return result;
}
public static int[] removeLast(int[] arr) {
int[] result = new int[arr.length - 1];
for (int i = 0; i < arr.length; i++) {
if (i == arr.length){continue;}
result[i - 1] = arr[i];
}
return result;
}
public static void main(String[] args) {
int[] arr = {1,2,3,4,5};
@ -37,4 +50,3 @@ public class ArrayManipulation {
}
// hallo
Loading…
Cancel
Save