#3146

Permutation Difference between Two Strings

newbie · 105 · lc easy +12 · 87.8% accepted · 190 likes · top 98%

Description

Given strings s and t where each character appears at most once in s and t is a rearrangement of s, return the sum of |index_s(c) - index_t(c)| for every character c.

Code

1
2
3