Create two sorted array and merge them in single array and the elements should not repeat inthe array..can u explain the program | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Create two sorted array and merge them in single array and the elements should not repeat inthe array..can u explain the program

29th Dec 2018, 11:21 AM
Nandhini Manickam
Nandhini Manickam - avatar
4 Answers
+ 2
Since you've tagged Python, there's an easy way to do that in Python. You can convert both lists into sets and then find the union of those two sets and convert the union set back to list. There you'll have a list which would be the result of two lists merged together and no repeating elements. I guess your question is not clear, should the resultant list be sorted as well?
29th Dec 2018, 12:25 PM
Шащи Ранжан
Шащи Ранжан - avatar
+ 1
Ok thank uuu
29th Dec 2018, 12:32 PM
Nandhini Manickam
Nandhini Manickam - avatar
+ 1
But I should not convert to sets... Without sets how I merge it... Explain please
29th Dec 2018, 12:33 PM
Nandhini Manickam
Nandhini Manickam - avatar
29th Dec 2018, 2:37 PM
Pulkit Kamboj
Pulkit Kamboj - avatar