Leetcode 3146. Permutation Difference between Two Strings
Given two strings s and t where t is a permutation of s and each character is unique, compute the permutation difference defined as the sum over all characters of the absolute difference between their indices in s and t. This is essentially an index-mapping problem: map each character to its position in s and sum |pos_s[c] - pos_t[c]| for all characters (n ≤ 26).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.