Data Structures & AlgorithmsModerateProduct Company SDE · trie round

Problem: What is the time complexity of building a trie for n strings of total length L?

  1. A. O(L)
  2. B. O(n^2)
  3. C. O(L log n)
  4. 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

Exams that ask this topic