Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CON-2830 Markdown Harmonious Fusion Exercise #2616

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions subjects/java/checkpoints/harmonious-fusion/ExerciseRunner.java
Original file line number Diff line number Diff line change
@@ -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]
}
}
51 changes: 51 additions & 0 deletions subjects/java/checkpoints/harmonious-fusion/README.md
Original file line number Diff line number Diff line change
@@ -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]
$
```
Loading