Problem: You are given strings S and T consisting of lowercase English letters.  You can perform the following operation on S any number of times:  Operation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.  Determine if S and T can be made equal by performing the operation zero or more times.

Submission attempts (in order):
import collections
S = (input())
T = (input())

count1 = collections.Counter(S)
count2 = collections.Counter(T)

count1=sorted(count1.items(), key=lambda x: x[1])
count2=sorted(count2.items(), key=lambda x: x[1])

if len(S) == len(T):
    if len(count1) != len(count2):
        print('No')
    else:
        for k1, k2 in zip(count1, count2):
            if k1[1] > 1:
                indexes = [i for i, x in enumerate(S) if x == k1[0]]
                indexes2 = [i for i, x in enumerate(S) if x == k2[0]]
                if indexes != indexes2:
                    print('No')
            else:
                print('Yes')
else:
    print('No')


#     if count1[k1] > 1:



import collections
S = (input())
T = (input())

count1 = collections.Counter(S)
count2 = collections.Counter(T)

count1=sorted(count1.items(), key=lambda x: x[1])
count2=sorted(count2.items(), key=lambda x: x[1])

if len(S) == len(T):
    if len(count1) != len(count2):
        print('No')
    else:
        for k1, k2 in zip(count1, count2):
            if k1[1] > 1:
                indexes = [i for i, x in enumerate(S) if x == k1[0]]
                indexes2 = [i for i, x in enumerate(S) if x == k1[0]]
                if indexes != indexes2:
                    print('No')
            else:
                print('Yes')
else:
    print('No')


#     if count1[k1] > 1:



import collections
S = (input())
T = (input())

count1 = collections.Counter(S)
count2 = collections.Counter(T)

count1=sorted(count1.items(), key=lambda x: x[1])
count2=sorted(count2.items(), key=lambda x: x[1])

if len(S) == len(T):
    if len(count1) != len(count2):
        print('No')
    else:
        for k1, k2 in zip(count1, count2):
            if k1[1] > 1:
                indexes = [i for i, x in enumerate(S) if x == k1[0]]
                indexes2 = [i for i, x in enumerate(T) if x == k2[0]]
                if indexes != indexes2:
                    print('No')
            else:
                print('Yes')
else:
    print('No')


#     if count1[k1] > 1:



import collections
S = (input())
T = (input())

count1 = collections.Counter(S)
count2 = collections.Counter(T)

count1=sorted(count1.items(), key=lambda x: x[1])
count2=sorted(count2.items(), key=lambda x: x[1])


indexes = []
indexes2 = []

if len(S) == len(T):
    if len(count1) != len(count2):
        print('No')
    else:
        for k1, k2 in zip(count1, count2):
            if k1[1] > 1:
                indexes.append((i for i, x in enumerate(S) if x == k1[0]))
                indexes2.append(i for i, x in enumerate(T) if x == k2[0])
        if set(indexes) == indexes2:
            print('Yes')
        else:
            print('No')
else:
    print('No')


#     if count1[k1] > 1:



import collections
S = (input())
T = (input())

count1 = collections.Counter(S)
count2 = collections.Counter(T)

count1=sorted(count1.items(), key=lambda x: x[1])
count2=sorted(count2.items(), key=lambda x: x[1])


indexes = []
indexes2 = []

if len(S) == len(T):
    if len(count1) != len(count2):
        print('No')
    else:
        for k1, k2 in zip(count1, count2):
            if k1[1] > 1:
                indexes.append(tuple([i for i, x in enumerate(S) if x == k1[0]]))
                indexes2.append(tuple([i for i, x in enumerate(T) if x == k2[0]]))
        if set(indexes) == set(indexes2):
            print('Yes')
        else:
            print('No')
else:
    print('No')


#     if count1[k1] > 1:



Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted