Ayush7614 / Daily-Coding-DS-ALGO-Practice

A open source project🚀 for bringing all interview💥💥 and competative📘 programming💥💥 question under one repo📐📐
https://daily-ds-algo.github.io/DS-Algo-Website/
MIT License
323 stars 474 forks source link

A C++ solution for Merge Without Extra Space (GFG- Hard) #1817

Closed geekySapien closed 3 years ago

geekySapien commented 3 years ago

Description

Given two sorted arrays arr1[] of size N and arr2[] of size M. Each array is sorted in non-decreasing order. Merge the two arrays into one sorted array in non-decreasing order without using any extra space.

Link to the Problem Statement: Link

Test Case 1

Input:

N = 4, M = 5

arr1[] = {1, 3, 5, 7}

arr2[] = {0, 2, 6, 8, 9}

Output: 0 1 2 3 5 6 7 8 9

Explanation:

Since we can't use any extra space, modify the given arrays to form

arr1[] = {0, 1, 2, 3}

arr2[] = {5, 6, 7, 8, 9}

Test Case 2

Input:

N = 2, M = 3

arr1[] = {10, 12}

arr2[] = {5, 18, 20}

Output: 5 10 12 18 20

Explanation:

Since we can't use any extra space, modify the given arrays to form

arr1[] = {5, 10}

arr2[] = {12, 18, 20}

Sir, I can work on this issue and provide C++ solution for the same. Kindly Assign me this issue under LGM-SOC'21

siddhi-244 commented 3 years ago

Can I try in python?

Rounak-chauhan commented 3 years ago

can i do in java?