From 2bee3d2db4fa4461860e742eec4d2450d4802122 Mon Sep 17 00:00:00 2001 From: amin Date: Thu, 27 Jun 2024 04:20:49 +0100 Subject: [PATCH] docs: adding subject and main --- .../harmonious-fusion/ExerciseRunner.java | 19 +++++++ .../checkpoints/harmonious-fusion/README.md | 51 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 subjects/java/checkpoints/harmonious-fusion/ExerciseRunner.java create mode 100644 subjects/java/checkpoints/harmonious-fusion/README.md diff --git a/subjects/java/checkpoints/harmonious-fusion/ExerciseRunner.java b/subjects/java/checkpoints/harmonious-fusion/ExerciseRunner.java new file mode 100644 index 000000000..4bc8ea4ae --- /dev/null +++ b/subjects/java/checkpoints/harmonious-fusion/ExerciseRunner.java @@ -0,0 +1,19 @@ +import java.util.Arrays; + +public class ExerciseRunner { + public static void main(String[] args) { + HarmoniousFusion merger = new HarmoniousFusion(); + + // Test case 1 + int[] arr1 = {1, 3, 5}; + int[] arr2 = {2, 4, 6}; + int[] mergedArray = merger.merge(arr1, arr2); + System.out.println(Arrays.toString(mergedArray)); // Expected output: [1, 2, 3, 4, 5, 6] + + // Test case 2 + int[] arr3 = {1, 3, 5, 7}; + int[] arr4 = {2, 4, 6}; + mergedArray = merger.merge(arr3, arr4); + System.out.println(Arrays.toString(mergedArray)); // Expected output: [1, 2, 3, 4, 5, 6, 7] + } +} \ No newline at end of file diff --git a/subjects/java/checkpoints/harmonious-fusion/README.md b/subjects/java/checkpoints/harmonious-fusion/README.md new file mode 100644 index 000000000..86ef24ef7 --- /dev/null +++ b/subjects/java/checkpoints/harmonious-fusion/README.md @@ -0,0 +1,51 @@ +## Harmonious Fusion +### Instructions + +Create a class `HarmoniousFusion` that provides a method to merge two sorted arrays into one sorted array. The merged array should also be sorted. + +### Expected Class + +```java +public class HarmoniousFusion { + public int[] merge(int[] arr1, int[] arr2) { + // Implementation to merge two sorted arrays into one sorted array + } +} +``` + +### Usage + +Here is a possible `ExerciseRunner.java` to test your class: + +```java +import java.util.Arrays; + +public class ExerciseRunner { + public static void main(String[] args) { + HarmoniousFusion merger = new HarmoniousFusion(); + + // Test case 1 + int[] arr1 = {1, 3, 5}; + int[] arr2 = {2, 4, 6}; + int[] mergedArray = merger.merge(arr1, arr2); + System.out.println(Arrays.toString(mergedArray)); // Expected output: [1, 2, 3, 4, 5, 6] + + // Test case 2 + int[] arr3 = {1, 3, 5, 7}; + int[] arr4 = {2, 4, 6}; + mergedArray = merger.merge(arr3, arr4); + System.out.println(Arrays.toString(mergedArray)); // Expected output: [1, 2, 3, 4, 5, 6, 7] + } +} +``` + +### Expected Output + +```shell +$ javac *.java -d build +$ java -cp build ExerciseRunner +[1, 2, 3, 4, 5, 6] +[1, 2, 3, 4, 5, 6, 7] +$ +``` +