345. Reverse Vowels of a String

1482. Minimum Number of Days to Make m Bouquets Given a string s, reverse only all the vowels in the string and return it. The vowels are ‘a’, ’e’, ‘i’, ‘o’, and ‘u’, and they can appear in both cases. 1 2 3 4 5 6 7 8 9 Example 1: Input: s = "hello" Output: "holle" Example 2: Input: s = "leetcode" Output: "leotcede" Constraints: 1 <= s.length <= 3 * 105 s consist of printable ASCII characters....

<span title='2021-07-19 00:00:00 +0000 UTC'>July 19, 2021</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;volyx

1624. Largest Substring Between Two Equal Characters

1624. Largest Substring Between Two Equal Characters Given a string s, return the length of the longest substring between two equal characters, excluding the two characters. If there is no such substring return -1. A substring is a contiguous sequence of characters within a string. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Example 1: Input: s = "aa" Output: 0 Explanation: The optimal substring here is an empty substring between the two 'a's....

<span title='2021-06-20 00:00:00 +0000 UTC'>June 20, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

244. Shortest Word Distance II

244. Shortest Word Distance II Design a data structure that will be initialized with a string array, and then it should answer queries of the shortest distance between two different strings from the array. Implement the WordDistance class: WordDistance(String[] wordsDict) initializes the object with the strings array wordsDict. int shortest(String word1, String word2) returns the shortest distance between word1 and word2 in the array wordsDict. 1 2 3 4 5 6 7 8 9 10 11 12 Example 1: Input ["WordDistance", "shortest", "shortest"] [[["practice", "makes", "perfect", "coding", "makes"]], ["coding", "practice"], ["makes", "coding"]] Output [null, 3, 1] Explanation WordDistance wordDistance = new WordDistance(["practice", "makes", "perfect", "coding", "makes"]); wordDistance....

<span title='2021-06-08 00:00:00 +0000 UTC'>June 8, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

245. Shortest Word Distance III

245. 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 these two words in the list. Note that word1 and word2 may be the same. It is guaranteed that they represent two individual words in the list. 1 2 3 4 5 6 7 8 9 Example 1: Input: wordsDict = ["practice", "makes", "perfect", "coding", "makes"], word1 = "makes", word2 = "coding" Output: 1 Example 2: Input: wordsDict = ["practice", "makes", "perfect", "coding", "makes"], word1 = "makes", word2 = "makes" Output: 3 Constraints:...

<span title='2021-06-08 00:00:00 +0000 UTC'>June 8, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

833. Find And Replace in String

833. Find And Replace in String To some string s, we will perform some replacement operations that replace groups of letters with new ones (not necessarily the same size). Each replacement operation has 3 parameters: a starting index i, a source word x and a target word y. The rule is that if x starts at position i in the original string S, then we will replace that occurrence of x with y....

<span title='2021-06-06 00:00:00 +0000 UTC'>June 6, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

438. Find All Anagrams in a String

438. Find All Anagrams in a String Given two strings s and p, return an array of all the start indices of p’s anagrams in s. You may return the answer in any order. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Example 1: Input: s = "cbaebabacd", p = "abc" Output: [0,6] Explanation: The substring with start index = 0 is "cba", which is an anagram of "abc"....

<span title='2021-05-11 00:00:00 +0000 UTC'>May 11, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1208. Get Equal Substrings Within Budget

1208. Get Equal Substrings Within Budget You are given two strings s and t of the same length. You want to change s to t. Changing the i-th character of s to i-th character of t costs |s[i] - t[i]| that is, the absolute difference between the ASCII values of the characters. You are also given an integer maxCost. Return the maximum length of a substring of s that can be changed to be the same as the corresponding substring of twith a cost less than or equal to maxCost....

<span title='2021-05-10 00:00:00 +0000 UTC'>May 10, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

443. String Compression

443. String Compression Given an array of characters chars, compress it using the following algorithm: Begin with an empty string s. For each group of consecutive repeating characters in chars: If the group’s length is 1, append the character to s. Otherwise, append the character followed by the group’s length. The compressed string s should not be returned separately, but instead be stored in the input character array chars. Note that group lengths that are 10 or longer will be split into multiple characters in chars....

<span title='2021-05-10 00:00:00 +0000 UTC'>May 10, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1207. Unique Number of Occurrences

1207. Unique Number of Occurrences Given an array of integers arr, write a function that returns true if and only if the number of occurrences of each value in the array is unique. 1 2 3 4 5 Example 1: Input: arr = [1,2,2,1,1,3] Output: true Explanation: The value 1 has 3 occurrences, 2 has 2 and 3 has 1. No two values have the same number of occurrences. 1 2 3 4 Example 2: Input: arr = [1,2] Output: false 1 2 3 4 Example 3: Input: arr = [-3,0,1,-3,1,1,1,-3,10,0] Output: true Constraints:...

<span title='2021-05-09 00:00:00 +0000 UTC'>May 9, 2021</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;volyx

1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence

1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence Given a sentence that consists of some words separated by a single space, and a searchWord. You have to check if searchWord is a prefix of any word in sentence. Return the index of the word in sentence where searchWord is a prefix of this word (1-indexed). If searchWord is a prefix of more than one word, return the index of the first word (minimum index)....

<span title='2021-05-08 00:00:00 +0000 UTC'>May 8, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

1844. Replace All Digits with Characters

1844. Replace All Digits with Characters You are given a 0-indexed string s that has lowercase English letters in its even indices and digits in its odd indices. There is a function shift(c, x), where c is a character and x is a digit, that returns the xth character after c. For example, shift(‘a’, 5) = ‘f’ and shift(‘x’, 0) = ‘x’. For every odd index i, you want to replace the digit s[i] with shift(s[i-1], s[i])....

<span title='2021-05-08 00:00:00 +0000 UTC'>May 8, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

859. Buddy Strings

859. Buddy Strings Given two strings a and b, return true if you can swap two letters in a so the result is equal to b, otherwise, return false. Swapping letters is defined as taking two indices i and j (0-indexed) such that i != j and swapping the characters at a[i] and a[j]. For example, swapping at indices 0 and 2 in “abcd” results in “cbad”. 1 2 3 4 5 Example 1: Input: a = "ab", b = "ba" Output: true Explanation: You can swap a[0] = 'a' and a[1] = 'b' to get "ba", which is equal to b....

<span title='2021-05-08 00:00:00 +0000 UTC'>May 8, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

211. Design Add and Search Words Data Structure

211. Design Add and Search Words Data Structure Design a data structure that supports adding new words and finding if a string matches any previously added string. Implement the WordDictionary class: WordDictionary() Initializes the object. void addWord(word) Adds word to the data structure, it can be matched later. bool search(word) Returns true if there is any string in the data structure that - matches word or false otherwise. word may contain dots ‘....

<span title='2021-05-06 00:00:00 +0000 UTC'>May 6, 2021</span>&nbsp;·&nbsp;4 min&nbsp;·&nbsp;volyx

72. Edit Distance

72. Edit Distance Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. You have the following three operations permitted on a word: Insert a character Delete a character Replace a character 1 2 3 4 5 6 7 8 Example 1: Input: word1 = "horse", word2 = "ros" Output: 3 Explanation: horse -> rorse (replace 'h' with 'r') rorse -> rose (remove 'r') rose -> ros (remove 'e') 1 2 3 4 5 6 7 8 9 10 Example 2: Input: word1 = "intention", word2 = "execution" Output: 5 Explanation: intention -> inention (remove 't') inention -> enention (replace 'i' with 'e') enention -> exention (replace 'n' with 'x') exention -> exection (replace 'n' with 'c') exection -> execution (insert 'u') Constraints:...

<span title='2021-05-05 00:00:00 +0000 UTC'>May 5, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

720. Longest Word in Dictionary

720. Longest Word in Dictionary Given an array of strings words representing an English Dictionary, return the longest word in words that can be built one character at a time by other words in words. If there is more than one possible answer, return the longest word with the smallest lexicographical order. If there is no answer, return the empty string. 1 2 3 4 5 Example 1: Input: words = ["w","wo","wor","worl","world"] Output: "world" Explanation: The word "world" can be built one character at a time by "w", "wo", "wor", and "worl"....

<span title='2021-05-04 00:00:00 +0000 UTC'>May 4, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx