Challenge: Check if Arrays are Disjoint
Building upon the previous challenge, we will learn how to check if two arrays are disjoint.
We'll cover the following
Problem Statement #
You have to implement the bool isDisjoint(int* arr1, int* arr2, int size1, int size2)
function, which checks whether two given arrays are disjoint or not.
Two arrays are disjoint if there are no common elements between them. The assumption is that there are no duplicate elements in each array.
Input #
Two arrays of integers and their lengths.
Output #
It returns true
if the two arrays are disjoint. Otherwise, it returns false
.
Sample Input #
arr1 = {9,4,3,1,-2,6,5}
arr2 = {7,10,8}
Sample Output #
true
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.