Array - 20: Union of Two Sorted Arrays

Опубликовано: 14 Октябрь 2024
на канале: Coding Simplified
14,722
237

Code: https://thecodingsimplified.com/union...
Solution:
One by one we'll compare both array values from starting
Whichever array value is smaller, put that value in new array or list & increase the index by 1
If both array value is same, then, put any array value in new array or list & inclrease both indexes(i, j)
At last, if you've any item left in any array, put all values of that array in new array
Time Complexity: O(n + m) for iterating the both array, where m - first array length, m - second array length

Please check video for more info:

This problem is similar to:
how to do union of two sorted array,
union of two sorted arrays,
print union of two sorted array,
union,
two sorted array,
array,
java tutorial,
coding simplified,
java

CHECK OUT CODING SIMPLIFIED
   / codingsimplified  

I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 400+ videos. My account is Partner Verified.

★☆★ VIEW THE BLOG POST: ★☆★
http://thecodingsimplified.com

★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★

https://www.youtube.com/codingsimplif...

★☆★ SEND EMAIL At: ★☆★
Email: [email protected]