Solved Leetcode 245. Shortest Word Distance III

source: https://leetcode.com/problems/shortest-word-distance-iii/description/ Shortest Word Distance III Given an array of strings wordsDict and two strings that already exist in the array word1 and word2, return the shortest distance between the occurrence of these two words in the list. Note that word1 and word2 may be the same. It is guaranteed that they represent two individual ...

Solved! Leetcode 567: Permutation in String

source: https://leetcode.com/problems/permutation-in-string/ Permutation in String Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise. In other words, return true if one of s1’s permutations is the substring of s2. Example 1: Input: s1 = “ab”, s2 = “eidbaooo” Output: true Explanation: s2 contains one permutation of ...

Leetcode 1061: Lexicographically Smallest Equivalent String

https://leetcode.com/problems/lexicographically-smallest-equivalent-string/description/ You are given two strings of the same length s1 and s2 and a string baseStr. We say s1[i] and s2[i] are equivalent characters. For example, if s1 = "abc" and s2 = "cde", then we have 'a' == 'c', 'b' == 'd', and 'c' == 'e'. Equivalent characters follow the usual rules of any equivalence relation: Reflexivity: 'a' == 'a'.Symmetry: 'a' == 'b' implies 'b' == 'a'.Transitivity: 'a' == 'b' and 'b' == 'c' implies 'a' == ...

Leetcode 944: Delete Columns to Make Sorted

You are given an array of n strings strs, all of the same lengths. The strings can be arranged such that there is one on each line, making a grid. For example, strs = ["abc", "bce", "cae"] can be arranged as: abc bce cae You want to <strong>delete</strong> the columns that are <strong>not sorted lexicographically</strong>. In the above example (0-indexed), columns 0 (<code>'a'</code>, <code>'b'</code>, <code>'c'</code>) ...