Tap here to switch tabs
Problem
Submissions

Problem: Permutation Difference between Two Strings

med
30 min
Try to solve the Permutation Difference between Two Strings problem.

Statement

You are given two strings s and t such that every character in s is unique and t is a permutation of s.

The permutation difference between s and t is defined as the sum of the absolute differences between the index of each character in s and the index of the identical character in t.

Return the permutation difference between s and t.

Constraints:

  • 1≤1 \leq s.length ≤26\leq 26

  • Each character occurs at most once in s.

  • t is a permutation of s.

  • s consists only of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Permutation Difference between Two Strings

med
30 min
Try to solve the Permutation Difference between Two Strings problem.

Statement

You are given two strings s and t such that every character in s is unique and t is a permutation of s.

The permutation difference between s and t is defined as the sum of the absolute differences between the index of each character in s and the index of the identical character in t.

Return the permutation difference between s and t.

Constraints:

  • 1≤1 \leq s.length ≤26\leq 26

  • Each character occurs at most once in s.

  • t is a permutation of s.

  • s consists only of lowercase English letters.