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
322 stars 474 forks source link

Union Of two sorted arrays #1147

Open creativeyashi opened 3 years ago

creativeyashi commented 3 years ago

Given two sorted arrays, find their union. Example:

Input : arr1[] = {1, 3, 4, 5, 7} arr2[] = {2, 3, 5, 6} Output : Union : {1, 2, 3, 4, 5, 6, 7}

It finds the union of two sorted arrays.

Problem link: https://practice.geeksforgeeks.org/problems/union-of-two-arrays3538/1

Programming language

Kindly assign it to me under LGMSOC'21

Jayati15 commented 3 years ago

`#include

include

using namespace std;

void solve(int a[],int b[],int n,int m) { set s; for(int i=0;i<n;i++) { s.insert(a[i]); }
for(int i=0;i<m;i++) { s.insert(b[i]); } set::iterator it; for(it=s.begin();it!=s.end();++it) { cout<<*it<<" "; } cout<<"\n";

}

int main() { int n,m; cin>>n>>m; int a[n],b[m]; for(int i=0;i<n;i++) { cin>>a[i]; } for(int i=0;i<m;i++) { cin>>b[i]; } solve(a,b,n,m);

  return 0;

} `

siddhi-244 commented 3 years ago

Can I try this in python ?

ravikr126 commented 3 years ago

yo can work on it @creativeyashi

ravikr126 commented 3 years ago

`#include

include

using namespace std;

void solve(int a[],int b[],int n,int m) { set s; for(int i=0;i<n;i++) { s.insert(a[i]); } for(int i=0;i<m;i++) { s.insert(b[i]); } set::iterator it; for(it=s.begin();it!=s.end();++it) { cout<<*it<<" "; } cout<<"\n";

}

int main() { int n,m; cin>>n>>m; int a[n],b[m]; for(int i=0;i<n;i++) { cin>>a[i]; } for(int i=0;i<m;i++) { cin>>b[i]; } solve(a,b,n,m);

  return 0;

} `

this is now a way to share code .this is opensource program

ravikr126 commented 3 years ago

Can I try this in python ?

you can create a new issue and mention it that you like to code in python

JahnaviKashyap19 commented 3 years ago

Please assign this to me. I can do it for C language