FPEvalDataset/LeetCodeProblem
0304
1{2 "id": 2550,3 "name": "words_within_two_edits_of_dictionary",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/words-within-two-edits-of-dictionary/",6 "date": "1665792000000",7 "task_description": "You are given two string arrays, `queries` and `dictionary`. All words in each array comprise of lowercase English letters and have the same length. In one **edit** you can take a word from `queries`, and change any letter in it to any other letter. Find all words from `queries` that, after a **maximum** of two edits, equal some word from `dictionary`. Return_ a list of all words from _`queries`_, __that match with some word from _`dictionary`_ after a maximum of **two edits**_. Return the words in the **same order** they appear in `queries`. **Example 1:** ``` **Input:** queries = [\"word\",\"note\",\"ants\",\"wood\"], dictionary = [\"wood\",\"joke\",\"moat\"] **Output:** [\"word\",\"note\",\"wood\"] **Explanation:** - Changing the 'r' in \"word\" to 'o' allows it to equal the dictionary word \"wood\". - Changing the 'n' to 'j' and the 't' to 'k' in \"note\" changes it to \"joke\". - It would take more than 2 edits for \"ants\" to equal a dictionary word. - \"wood\" can remain unchanged (0 edits) and match the corresponding dictionary word. Thus, we return [\"word\",\"note\",\"wood\"]. ``` **Example 2:** ``` **Input:** queries = [\"yes\"], dictionary = [\"not\"] **Output:** [] **Explanation:** Applying any two edits to \"yes\" cannot make it equal to \"not\". Thus, we return an empty array. ``` **Constraints:** `1 <= queries.length, dictionary.length <= 100` `n == queries[i].length == dictionary[j].length` `1 <= n <= 100` All `queries[i]` and `dictionary[j]` are composed of lowercase English letters.",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "queries = [\"word\",\"note\",\"ants\",\"wood\"], dictionary = [\"wood\",\"joke\",\"moat\"]",12 "output": "[\"word\",\"note\",\"wood\"] "13 },14 {15 "label": "Example 2",16 "input": "queries = [\"yes\"], dictionary = [\"not\"]",17 "output": "[] "18 }19 ],20 "private_test_cases": [],21 "haskell_template": "twoEditWords :: [String] -> [String] -> [String]\ntwoEditWords queries dictionary ",22 "ocaml_template": "let twoEditWords (queries: string list) (dictionary: string list) : string list = ",23 "scala_template": "def twoEditWords(queries: List[String],dictionary: List[String]): List[String] = { \n \n}",24 "java_template": "public static List<String> twoEditWords(List<String> queries, List<String> dictionary) {\n\n}",25 "python_template": "class Solution(object):\n def twoEditWords(self, queries, dictionary):\n \"\"\"\n :type queries: List[str]\n :type dictionary: List[str]\n :rtype: List[str]\n \"\"\"\n "26}