How to find common elements in two unsorted arrays with sizes n and m avoiding double for loop? One of…