Leetcode Problem 2839. Check if Strings Can be Made Equal With Operations I

2839. Check if Strings Can be Made Equal With Operations I

Leetcode Solutions

Sorting Substrings Approach

  1. Extract the characters at even indices (0 and 2) from both s1 and s2 and sort them.
  2. Extract the characters at odd indices (1 and 3) from both s1 and s2 and sort them.
  3. Compare the sorted substrings of s1 and s2 for both even and odd indices.
  4. If both comparisons are equal, return true.
  5. Otherwise, return false.
UML Thumbnail

Brute Force Swapping Approach

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...