Merge [1,3,5] and [2,4,6]; print merged.
Toolliyo Coach
Progressive help: Nudge → Guide → Approach. Full solution stays behind the Solution tab.
Editor is open — no login wall to practice.
| Test | Status | Details |
|---|
Ready — edit the code above and click Run or Submit.
using System;
class Program
{
static void Main()
{
int[] a = { 1, 3, 5 }, b = { 2, 4, 6 };
int i = 0, j = 0;
var outList = new System.Collections.Generic.List<int>();
while (i < a.Length && j < b.Length)
outList.Add(a[i] <= b[j] ? a[i++] : b[j++]);
while (i < a.Length) outList.Add(a[i++]);
while (j < b.Length) outList.Add(b[j++]);
Console.WriteLine(string.Join(" ", outList));
}
}
Prefer Coach (Nudge → Guide → Approach) before revealing. No forced signup.
Two-pointer merge — merge sort building block.
Sign in to save and review your submission history. You can still Run code on the Editor tab as a guest.
Sign in