Trie
Trie
Thirty questions on tries, for prefix matching, autocomplete, and word-search problems.
Count Prefix and Suffix Pairs I
easyYou are given a 0-indexed string array words.
Longest Common Prefix
easyWrite a function to find the longest common prefix string amongst an array of strings.
Maximum Strong Pair XOR I
easyYou are given a 0-indexed integer array nums.
Camelcase Matching
mediumGiven an array of strings queries and a string pattern, return a boolean array answer where answer[i] is true if queries[i] matches pattern, and false otherwise.
Extra Characters in a String
mediumYou are given a 0-indexed string s and a dictionary of words dictionary.
Find the Length of the Longest Common Prefix
mediumYou are given two arrays with positive integers arr1 and arr2.
K Divisible Elements Subarrays
mediumGiven an integer array nums and two integers k and p, return the number of distinct subarrays, which have at most k elements that are divisible by p.
Lexicographical Numbers
mediumGiven an integer n, return all the numbers in the range [1, n] sorted in lexicographical order.
Longest Word in Dictionary
mediumGiven 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.
Maximum XOR of Two Numbers in an Array
mediumGiven an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n.
Minimum Number of Valid Strings to Form Target I
mediumYou are given an array of strings words and a string target.
Number of Matching Subsequences
mediumGiven a string s and an array of strings words, return the number of words[i] that is a subsequence of s.
Partition String
mediumGiven a string s, partition it into unique segments according to the following procedure: Return an array of strings segments, where segments[i] is the ith segment created.
Remove Sub-Folders from the Filesystem
mediumGiven a list of folders folder, return the folders after removing all sub-folders in those folders.
Replace Words
mediumIn English, we have a concept called root, which can be followed by some other word to form another longer word - let's call this word derivative.
Search Suggestions System
mediumYou are given an array of strings products and a string searchWord.
Short Encoding of Words
mediumA valid encoding of an array of words is any reference string s and array of indices indices such that: Given an array of words, return the length of the shortest reference string...
Shortest Uncommon Substring in an Array
mediumYou are given an array arr of size n consisting of non-empty strings.
Top K Frequent Words
mediumGiven an array of strings words and an integer k, return the k most frequent strings.
Word Break
mediumGiven a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words.
Words Within Two Edits of Dictionary
mediumYou are given two string arrays, queries and dictionary.
Concatenated Words
hardGiven an array of strings words (without duplicates), return all the concatenated words in the given list of words.
Count Pairs With XOR in a Range
hardGiven a (0-indexed) integer array nums and two integers low and high, return the number of nice pairs.
Count Prefix and Suffix Pairs II
hardYou are given a 0-indexed string array words.
Delete Duplicate Folders in System
hardDue to a bug, there are many duplicate folders in a file system.
Distinct Echo Substrings
hardReturn the number of distinct non-empty substrings of text that can be written as the concatenation of some string with itself (i.e.
K-th Smallest in Lexicographical Order
hardGiven two integers n and k, return the kth lexicographically smallest integer in the range [1, n].
Longest Common Prefix of K Strings After Removal
hardYou are given an array of strings words and an integer k.
Longest Common Suffix Queries
hardYou are given two arrays of strings wordsContainer and wordsQuery.
Maximum Genetic Difference Query
hardThere is a rooted tree consisting of n nodes numbered 0 to n - 1.