Two arrays are called similar if one can be obtained from another by swapping at most one pair of elements in one of the arrays : # I Solved the Problem but i need to make it run in 4 seconds(Python3) for all inputs,being a python newbie, i have no clue...any ideas for making this more efficient..Here is my Solution...
    def areSimilar (a,b):
        counter=0
        for i in range(len(a)):
            for j in range(len(b)):
                if counter < 1 and a[i]!=b[i]:
                    if a[i]==b[j]:
                        temp=b[j]
                        b[j]=b[i]
                        b[i]=temp
                        counter+=1
                    else:
                        flag=False
    
        if a == b:
            flag=True
        else:
            flag = False
            
        return flag
    
    a= [832, 998, 148, 570, 533, 561, 894, 147, 455, 279]
    b= [832, 998, 148, 570, 533, 561, 455, 147, 894, 279]
    p=areSimilar(a,b)


# I think the nested loops are the Problem