Data Structures & AlgorithmsModerateProduct Company SDE · trie round
Problem: What is the time complexity of building a trie for n strings of total length L?
- A. O(L)
- B. O(n^2)
- C. O(L log n)
- D. O(n log L)
Correct answer: A. O(L)
Each character is inserted once into the trie, so the total work is proportional to L.
More Coding Interview Problems questions
- Problem: What is a 'bridge' in an undirected graph?
- Problem: Which algorithm finds the strongly connected components of a directed graph using a single DFS with a stack?
- Problem: What is the maximum number of edges in a bipartite graph on n vertices with sides of size n/2?
- Problem: Which problem is solved by Dijkstra's algorithm on a graph whose edge weights are small integers, using buckets (Dial's algorithm)?
- Problem: What is the best known approach for range-mode queries on a static array?
- Problem: Which concept describes the minimum number of comparisons to find the maximum of n numbers?