Practice Permutation Difference between Two Strings
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given two strings s and t such that every character occurs at most once in s and t is a permutation of s. The permutation difference between s and t is defined as the sum of the absolute difference between the index of the occurrence of each character in s and the index of the occurrence of the same character in t. Return the permutation difference between s and t.
Source: Permutation Difference between Two Strings on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "abc", t = "bac"
2
# Example 2
s = "abcde", t = "edbac"
12
Constraints
Related LeetCode Problems
Practice more problems similar to Permutation Difference between Two Strings.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.