Algorithm

Check if Strings Can be Made Equal With Operations I

Solution
class Solution:
    def canBeEqual(self, s1: str, s2: str) -> bool:
        # Extract and sort even-indexed characters
        evens_s1 = sorted([s1[0], s1[2]])
        evens_s2 = sorted([s2[0], s2[2]])
        
        # Extract and sort odd-indexed characters
        odds_s1 = sorted([s1[1], s1[3]])
        odds_s2 = sorted([s2[1], s2[3]])
        
        # Both groups must match perfectly
        return evens_s1 == evens_s2 and odds_s1 == odds_s2