Trie Problems
Master trie problems with AI-powered solutions. Get instant coding assistance during your technical interviews for all 38 problems in this category.
Total Problems: 38
Easy: 2
Medium: 20
Hard: 16
Showing 38 of 38 problems
Problems
Scroll within this area to browse all problems
#
Title
Difficulty
Trie LeetCode Problems List
- 14. Longest Common Prefix - Easy - TrieWrite a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "".... Topics: Array, String, Trie
- 208. Implement Trie (Prefix Tree) - Medium - TrieA trie (pronounced as "try") or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are va... Topics: Hash Table, String, Design, Trie
- 212. Word Search II - Hard - TrieGiven an m x n board of characters and a list of strings words, return all words on the board. Each word must be constructed from letters of sequentia... Topics: Array, String, Backtracking, Trie, Matrix
- 720. Longest Word in Dictionary - Medium - TrieGiven 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 othe... Topics: Array, Hash Table, String, Trie, Sorting
- 139. Word Break - Medium - TrieGiven 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 wor... Topics: Array, Hash Table, String, Dynamic Programming, Trie, Memoization
- 336. Palindrome Pairs - Hard - TrieYou are given a 0-indexed array of unique strings words. A palindrome pair is a pair of integers (i, j) such that: 0 <= i, j < words.length, i != j, a... Topics: Array, Hash Table, String, Trie
- 2550. Words Within Two Edits of Dictionary - Medium - TrieYou are given two string arrays, queries and dictionary. All words in each array comprise of lowercase English letters and have the same length. In on... Topics: Array, String, Trie
- 140. Word Break II - Hard - TrieGiven a string s and a dictionary of strings wordDict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all ... Topics: Array, Hash Table, String, Dynamic Programming, Backtracking, Trie, Memoization
- 211. Design Add and Search Words Data Structure - Medium - TrieDesign a data structure that supports adding new words and finding if a string matches any previously added string. Implement the WordDictionary class... Topics: String, Depth-First Search, Design, Trie
- 3329. Find the Length of the Longest Common Prefix - Medium - TrieYou are given two arrays with positive integers arr1 and arr2. A prefix of a positive integer is an integer formed by one or more of its digits, start... Topics: Array, Hash Table, String, Trie
- 3376. Longest Common Suffix Queries - Hard - TrieYou are given two arrays of strings wordsContainer and wordsQuery. For each wordsQuery[i], you need to find a string from wordsContainer that has the ... Topics: Array, String, Trie
- 421. Maximum XOR of Two Numbers in an Array - Medium - TrieGiven an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n.... Topics: Array, Hash Table, Bit Manipulation, Trie
- 1397. Search Suggestions System - Medium - TrieYou are given an array of strings products and a string searchWord. Design a system that suggests at most three product names from products after each... Topics: Array, String, Binary Search, Trie, Sorting, Heap (Priority Queue)
- 746. Prefix and Suffix Search - Hard - TrieDesign a special dictionary that searches the words in it by a prefix and a suffix. Implement the WordFilter class: WordFilter(string[] words) Initial... Topics: Array, Hash Table, String, Design, Trie
- 3197. Maximum Strong Pair XOR II - Hard - TrieYou are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition: |x - y| <= min(x, y) Y... Topics: Array, Hash Table, Bit Manipulation, Trie, Sliding Window
- 648. Replace Words - Medium - TrieIn 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. For... Topics: Array, Hash Table, String, Trie
- 386. Lexicographical Numbers - Medium - TrieGiven an integer n, return all the numbers in the range [1, n] sorted in lexicographical order. You must write an algorithm that runs in O(n) time and... Topics: Depth-First Search, Trie
- 676. Implement Magic Dictionary - Medium - TrieDesign a data structure that is initialized with a list of different words. Provided a string, you should determine if you can change exactly one char... Topics: Hash Table, String, Depth-First Search, Design, Trie
- 3784. Longest Common Prefix of K Strings After Removal - Hard - TrieYou are given an array of strings words and an integer k. For each index i in the range [0, words.length - 1], find the length of the longest common p... Topics: Array, String, Trie
- 1826. Maximum XOR With an Element From Array - Hard - TrieYou are given an array nums consisting of non-negative integers. You are also given a queries array, where queries[i] = [xi, mi]. The answer to the it... Topics: Array, Bit Manipulation, Trie
- 2755. Extra Characters in a String - Medium - TrieYou are given a 0-indexed string s and a dictionary of words dictionary. You have to break s into one or more non-overlapping substrings such that eac... Topics: Array, Hash Table, String, Dynamic Programming, Trie
- 1350. Remove Sub-Folders from the Filesystem - Medium - TrieGiven a list of folders folder, return the folders after removing all sub-folders in those folders. You may return the answer in any order. If a folde... Topics: Array, String, Depth-First Search, Trie
- 2079. Delete Duplicate Folders in System - Hard - TrieDue to a bug, there are many duplicate folders in a file system. You are given a 2D array paths, where paths[i] is an array representing an absolute p... Topics: Array, Hash Table, String, Trie, Hash Function
- 1282. Number of Valid Words for Each Puzzle - Hard - TrieWith respect to a given puzzle string, a word is valid if both the following conditions are satisfied: word contains the first letter of puzzle. For e... Topics: Array, Hash Table, String, Bit Manipulation, Trie
- 3905. Partition String - Medium - TrieGiven a string s, partition it into unique segments according to the following procedure: Start building a segment beginning at index 0. Continue exte... Topics: Hash Table, String, Trie, Simulation
- 1080. Camelcase Matching - Medium - TrieGiven 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... Topics: Array, Two Pointers, String, Trie, String Matching
- 692. Top K Frequent Words - Medium - TrieGiven an array of strings words and an integer k, return the k most frequent strings. Return the answer sorted by the frequency from highest to lowest... Topics: Array, Hash Table, String, Trie, Sorting, Heap (Priority Queue), Bucket Sort, Counting
- 2494. Sum of Prefix Scores of Strings - Hard - TrieYou are given an array words of size n consisting of non-empty strings. We define the score of a string term as the number of strings words[i] such th... Topics: Array, String, Trie, Counting
- 1433. Encrypt and Decrypt Strings - Hard - TrieYou are given a character array keys containing unique characters and a string array values containing strings of length 2. You are also given another... Topics: Array, Hash Table, String, Design, Trie
- 3309. Count Prefix and Suffix Pairs I - Easy - TrieYou are given a 0-indexed string array words. Let's define a boolean function isPrefixAndSuffix that takes two strings, str1 and str2: isPrefixAndSuff... Topics: Array, String, Trie, Rolling Hash, String Matching, Hash Function
- 1097. Stream of Characters - Hard - TrieDesign an algorithm that accepts a stream of characters and checks if a suffix of these characters is a string of a given array of strings words. For ... Topics: Array, String, Design, Trie, Data Stream
- 440. K-th Smallest in Lexicographical Order - Hard - TrieGiven two integers n and k, return the kth lexicographically smallest integer in the range [1, n].... Topics: Trie
- 3356. Shortest Uncommon Substring in an Array - Medium - TrieYou are given an array arr of size n consisting of non-empty strings. Find a string array answer of size n such that: answer[i] is the shortest substr... Topics: Array, Hash Table, String, Trie
- 808. Number of Matching Subsequences - Medium - TrieGiven a string s and an array of strings words, return the number of words[i] that is a subsequence of s. A subsequence of a string is a new string ge... Topics: Array, Hash Table, String, Binary Search, Dynamic Programming, Trie, Sorting
- 677. Map Sum Pairs - Medium - TrieDesign a map that allows you to do the following: Maps a string key to a given value. Returns the sum of the values that have a key with a prefix equa... Topics: Hash Table, String, Design, Trie
- 839. Short Encoding of Words - Medium - TrieA valid encoding of an array of words is any reference string s and array of indices indices such that: words.length == indices.length The reference s... Topics: Array, Hash Table, String, Trie
- 3305. Count Prefix and Suffix Pairs II - Hard - TrieYou are given a 0-indexed string array words. Let's define a boolean function isPrefixAndSuffix that takes two strings, str1 and str2: isPrefixAndSuff... Topics: Array, String, Trie, Rolling Hash, String Matching, Hash Function
- 472. Concatenated Words - Hard - TrieGiven an array of strings words (without duplicates), return all the concatenated words in the given list of words. A concatenated word is defined as ... Topics: Array, String, Dynamic Programming, Depth-First Search, Trie, Sorting
Related LeetCode Topics
- Array LeetCode Problems
- Backtracking LeetCode Problems
- Biconnected Component LeetCode Problems
- Binary Indexed Tree LeetCode Problems
- Binary Search LeetCode Problems
- Binary Search Tree LeetCode Problems
- Binary Tree LeetCode Problems
- Bit Manipulation LeetCode Problems
- Bitmask LeetCode Problems
- Brainteaser LeetCode Problems
- Breadth-First Search LeetCode Problems
- Bucket Sort LeetCode Problems
- Combinatorics LeetCode Problems
- Concurrency LeetCode Problems
- Counting LeetCode Problems
- Counting Sort LeetCode Problems
- Data Stream LeetCode Problems
- Database LeetCode Problems
- Depth-First Search LeetCode Problems
- Design LeetCode Problems