760 Find Anagram Mappings
A = [12, 28, 46, 32, 50]
B = [50, 12, 32, 46, 28][1, 4, 3, 2, 0]import collections
class Solution:
def anagramMappings(self, A, B):
"""
:type A: List[int]
:type B: List[int]
:rtype: List[int]
"""
B_map = collections.defaultdict(list)
for i, b in enumerate(B):
B_map[b].append(i)
P = []
for a in A:
P.append(B_map[a].pop())
return PLast updated