From 44afb413c1e0127d3090ff57bfa68c7b698eb57e Mon Sep 17 00:00:00 2001 From: Florentin Koepff Date: Fri, 22 Apr 2022 18:06:24 +0200 Subject: [PATCH] RemoveLast --- ArrayManipulation.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ArrayManipulation.java b/ArrayManipulation.java index 762da15..120a5f6 100644 --- a/ArrayManipulation.java +++ b/ArrayManipulation.java @@ -26,6 +26,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) { @@ -36,5 +49,4 @@ public class ArrayManipulation { -} -// hallo \ No newline at end of file +} \ No newline at end of file