FPEvalDataset/LeetCodeProblem
0302
1{2 "id": 3412,3 "name": "permutation_difference_between_two_strings",4 "difficulty": "Easy",5 "link": "https://leetcode.com/problems/permutation-difference-between-two-strings/",6 "date": "2024-05-05 00:00:00",7 "task_description": "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`. **Example 1:** **Input:** s = \"abc\", t = \"bac\" **Output:** 2 **Explanation:** For `s = \"abc\"` and `t = \"bac\"`, the permutation difference of `s` and `t` is equal to the sum of: The absolute difference between the index of the occurrence of `\"a\"` in `s` and the index of the occurrence of `\"a\"` in `t`. The absolute difference between the index of the occurrence of `\"b\"` in `s` and the index of the occurrence of `\"b\"` in `t`. The absolute difference between the index of the occurrence of `\"c\"` in `s` and the index of the occurrence of `\"c\"` in `t`. That is, the permutation difference between `s` and `t` is equal to `|0 - 1| + |1 - 0| + |2 - 2| = 2`. **Example 2:** **Input:** s = \"abcde\", t = \"edbac\" **Output:** 12 **Explanation:** The permutation difference between `s` and `t` is equal to `|0 - 3| + |1 - 2| + |2 - 4| + |3 - 1| + |4 - 0| = 12`. **Constraints:** `1 <= s.length <= 26` Each character occurs at most once in `s`. `t` is a permutation of `s`. `s` consists only of lowercase English letters.",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "s = \"abc\", t = \"bac\"",12 "output": "2 "13 },14 {15 "label": "Example 2",16 "input": "s = \"abcde\", t = \"edbac\"",17 "output": "12 "18 }19 ],20 "private_test_cases": [21 {22 "input": [23 "\"ovmuxe\"",24 "\"umevxo\""25 ],26 "output": 1427 },28 {29 "input": [30 "\"jeqiopgvdkm\"",31 "\"jikpomeqgvd\""32 ],33 "output": 3234 },35 {36 "input": [37 "\"kmrycdgajlwiouzqsnex\"",38 "\"nyzqorgwmxcdlesujiak\""39 ],40 "output": 14241 },42 {43 "input": [44 "\"ulpgofezvtrdmjsaynx\"",45 "\"yfteunlvxdsjzgamorp\""46 ],47 "output": 12448 },49 {50 "input": [51 "\"tqenyijdapoxfkmwvzrchlu\"",52 "\"velicpqzfjhrkydamwxuton\""53 ],54 "output": 18455 },56 {57 "input": [58 "\"cdv\"",59 "\"cdv\""60 ],61 "output": 062 },63 {64 "input": [65 "\"uacxvrdlmtwgybpshjfnqiz\"",66 "\"yazjiuqgpvshncfdtxwmbrl\""67 ],68 "output": 21669 },70 {71 "input": [72 "\"gteqpfdyuail\"",73 "\"aytgfudleqip\""74 ],75 "output": 4676 },77 {78 "input": [79 "ajfbiwcxsudznghrlqyovpktm",80 "dtzbrspfhavgmnuxcqlkwjoyi"81 ],82 "output": 20683 },84 {85 "input": [86 "gfbkolwtcimqp",87 "fcpobkwqitgml"88 ],89 "output": 4890 }91 ],92 "haskell_template": "findPermutationDifference :: String -> String -> Int\nfindPermutationDifference s t ",93 "ocaml_template": "let findPermutationDifference (s: string) (t: string) : int = ",94 "scala_template": "def findPermutationDifference(s: String,t: String): Int = { \n \n}",95 "java_template": "class Solution {\n public int findPermutationDifference(String s, String t) {\n \n }\n}",96 "python_template": "class Solution(object):\n def findPermutationDifference(self, s, t):\n \"\"\"\n :type s: str\n :type t: str\n :rtype: int\n \"\"\"\n "97}