Move Pieces to Obtain a String LeetCode solution in Python
1class Solution:2def canChange(self, A: str, B: str) -> bool:3P = lambda c: c != "_"4I = lambda s, x: [i for i, c in enumerate(s) if c == x]5G = lambda d, p: all(p(x, y) for x, y in zip(I(A, d), I(B, d)))6S = lambda: [*filter(P, A)] == [*filter(P, B)]7return S() and G("L", ge) and G("R", le)8910# 1. 2. 3.