You are given a string query and an array of strings words.
The edit distance (Levenshtein distance) between two strings is the minimum number of single-character operations (insert a character, delete a character, or substitute a character) needed to transform one string into the other.
Return the element of words with the smallest edit distance to query. If several words share the smallest distance, return the lexicographically smallest of them.
Input: query = "horse", words = ["ros", "rose", "house"]
Output: "house"
Explanation: The edit distances to "horse" are: "ros" -> 3, "rose" -> 2,
"house" -> 1 (substitute 'r' with 'u'). "house" is the unique minimum.
Input: query = "cat", words = ["cut", "cot", "car"]
Output: "car"
Explanation: All three words are at edit distance 1 from "cat". The
lexicographically smallest of them is "car".
words.length ≤1000query.length, words[i].length ≤100query and all words[i] consist of lowercase English letters.