How to check if two arrays have the same set of digits in Python

1 Answer

0 votes
def have_same_set_of_digits(arr1, arr2):
    len1 = len(arr1)
    len2 = len(arr2)

    if (len1 != len2):
        return False

    for i in range(0, len1 - 1):
        found = False
        for j in range(0, len1):
            if (arr1[i] == arr2[j]):
                found = True
                break
        if (found == False):
            return False;
            
    return True
 
 
arr1 = [1, 3, 8, 5, 9, 2]
arr2 = [2, 9, 1, 8, 2, 5]

if (have_same_set_of_digits(arr1, arr2)):
    print("Yes")
else:
    print("No")
    
    
    
'''
run:

No

'''

 



answered Dec 4, 2020 by avibootz
...