Tap here to switch tabs
Problem
Submissions

Problem: K-Similar Strings

Try to solve the K-Similar Strings problem.

Statement

Two strings s1 and s2 are considered kk similar (for some non negative integer kk) if s1 can be transformed into s2 by swapping the positions of two characters exactly kk times.

Given two anagrams s1 and s2, return the minimum value of kk for which s1 and s2 are kk similar.

Constraints:

  • 1≤1 \leq s1.length ≤20\leq 20

  • s2.length == s1.length

  • s1 and s2 contain only lowercase English letters from the set {'a', 'b', 'c', 'd', 'e', 'f'}.

  • s2 is an anagram of s1.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: K-Similar Strings

Try to solve the K-Similar Strings problem.

Statement

Two strings s1 and s2 are considered kk similar (for some non negative integer kk) if s1 can be transformed into s2 by swapping the positions of two characters exactly kk times.

Given two anagrams s1 and s2, return the minimum value of kk for which s1 and s2 are kk similar.

Constraints:

  • 1≤1 \leq s1.length ≤20\leq 20

  • s2.length == s1.length

  • s1 and s2 contain only lowercase English letters from the set {'a', 'b', 'c', 'd', 'e', 'f'}.

  • s2 is an anagram of s1.