Find the shortest unique prefix for every word in an array
Given an array of words where no word is the prefix of another, find the shortest unique prefix to identify each word in the array uniquely.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven an array of words where no word is the prefix of another, find the shortest unique prefix to identify each word in the array uniquely.
Find duplicate rows present in a given binary matrix by traversing the matrix only once.
Implement insert, search, and delete operations on Trie data structure. Assume that the input consists of only lowercase letters a–z.
This post covers memory-efficient implementation of Trie data structure in C++ using the map data structure. Trie is a tree-based data structure, which is used for efficient retrieval of a key in a large dataset of strings.
Find the longest common prefix (LCP) in a given set of strings.
Lexicographic sorting: Given a set of strings, print them in lexicographic order (dictionary/alphabetical order).
Given a huge set of words with duplicates present, find the maximum occurring word in it. If two words have the same count, return any one of them.
Given a huge set of words with duplicates present and a positive integer k, find the first k–maximum occurring words in it.
Given a dictionary of words, determine if a given string can be segmented into a space-separated sequence of one or more dictionary words.
Trie is a tree-based data structure used for efficient retrieval of a key in a huge set of strings. This post covers the C++ implementation of the Trie data structure, which supports insertion, deletion, and search operations.
Trie is a tree-based data structure used for efficient retrieval of a key in a huge word set. In this post, we will implement the Trie data structure in Java.
Given an M × N boggle board, find a list of all possible words that can be formed by a sequence of adjacent characters on the board.