• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
November 11, 2024 0

PROBLEM OF THE DAY : 10/11/2024 | Union of Two Sorted Arrays with Distinct Elements

Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Kunal Jain We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Arrays but also build up problem-solving skills.

Given two sorted arrays a[] and b[], where each array contains distinct elements , the task is to return the elements in the union of the two arrays in sorted order.

Union of two arrays can be defined as the set containing distinct common elements that are present in either of the arrays.

Examples:

Input: a[] = [1, 2, 3, 4, 5], b[] = [1, 2, 3, 6, 7]
Output: 1 2 3 4 5 6 7
Explanation: Distinct elements including both the arrays are: 1 2 3 4 5 6 7.

Give the problem a try before going through the video. All the best!!!
Problem Link: https://www.geeksforgeeks.org/problems/union-of-two-sorted-arrays-with-distinct-elements/1