Back to problems

Code Craft: Similar Restaurant Names (K-Swap Anagram)

Algorithm · DoorDash · Easy

Requirements Implement the following function: The function receives two strings, s1 and s2, plus an integer k. Return true exactly when s1 can be changed into s2 using no more than k swaps. A swap may exchange any two character positions in s1. The strings must have equal lengths. If their lengths differ, return false immediately. Examples Example 1 No changes are needed because the strings already match. Example 2 Swapping the characters at positions 1 and 2 changes "abcd"…

Checking your access…