Leetcode 1556 Solution
This article provides solution to leetcode question 1556 (make-two-arrays-equal-by-reversing-sub-arrays).
Access this page by simply typing in "lcs 1556" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/make-two-arrays-equal-by-reversing-sub-arrays
Solution
class Solution:
def canBeEqual(self, target: List[int], arr: List[int]) -> bool:
m1 = collections.defaultdict(int)
m2 = collections.defaultdict(int)
for v in arr:
m1[v] += 1
for v in target:
m2[v] += 1
return m1 == m2