Challenge 2: Check if Arrays are Disjoint

Building upon the previous challenge, you will learn how to check if two arrays are disjoint.

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

This is two arrays of integers and their lengths.

Output

It returns true if the two arrays are disjointed. If not, 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 80+ hands-on prep courses.