Merge Arrays

Medium Arrays (1D)
Solve in Playground →

Problem Statement

Write a C program to merge two sorted arrays into a single sorted array.

Input Format

Line 1: N1. Line 2: N1 elements. Line 3: N2. Line 4: N2 elements.

Output Format

Print the merged sorted array separated by a space.

Constraints

1 <= N1, N2 <= 500

Sample Input

3
1 3 5
3
2 4 6

Sample Output

1 2 3 4 5 6

Explanation

Merging [1, 3, 5] and [2, 4, 6] produces [1, 2, 3, 4, 5, 6].

Starter Code

#include <stdio.h>

int main() {
    int n1, n2;
    if (scanf("%d", &n1) == 1) {
        int a[n1];
        for (int i = 0; i < n1; i++) scanf("%d", &a[i]);
        if (scanf("%d", &n2) == 1) {
            int b[n2];
            for (int i = 0; i < n2; i++) scanf("%d", &b[i]);
            // Write your code here
        }
    }
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used