From 8be8c921e61b870a1686b16ed9cec7a364a168e5 Mon Sep 17 00:00:00 2001 From: SteffenLm <33038091+SteffenLm@users.noreply.github.com> Date: Sun, 8 Oct 2023 00:02:03 +0200 Subject: [PATCH 1/2] Implement solution --- Exercise.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Exercise.java b/Exercise.java index 3c092f9..2aa48ec 100644 --- a/Exercise.java +++ b/Exercise.java @@ -1,6 +1,22 @@ public class Exercise { public static void main(String[] args) { - // implement exercise here + int[][] input = { { 5, 8, 2 }, { 9, 6, 10 }, { 10, 2, 7 }, { 1, 9, 5 } }; + int[][] output = new int[input.length][2]; + + for (int i = 0; i < input.length; i++) { + int min = input[i][0]; + int max = input[i][0]; + for (int j = 0; j < input[i].length; j++) { + max = (input[i][j] > max) ? input[i][j] : max; + min = (input[i][j] < min) ? input[i][j] : min; + } + output[i][0] = min; + output[i][1] = max; + } + System.out.println("MIN - MAX"); + for (int i = 0; i < output.length; i++) { + System.out.println(output[i][0] + " - " + output[i][1]); + } } } From 9dbca913f3cd4dcd383b5725353b2831cf590679 Mon Sep 17 00:00:00 2001 From: github-actions <> Date: Sat, 7 Oct 2023 22:03:01 +0000 Subject: [PATCH 2/2] Google Java Format --- Exercise.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exercise.java b/Exercise.java index 2aa48ec..e5b5297 100644 --- a/Exercise.java +++ b/Exercise.java @@ -1,7 +1,7 @@ public class Exercise { public static void main(String[] args) { - int[][] input = { { 5, 8, 2 }, { 9, 6, 10 }, { 10, 2, 7 }, { 1, 9, 5 } }; + int[][] input = {{5, 8, 2}, {9, 6, 10}, {10, 2, 7}, {1, 9, 5}}; int[][] output = new int[input.length][2]; for (int i = 0; i < input.length; i++) {