Back to problems

Trie Data Structure

Algorithm · Bloomberg · Medium

Given an array of strings, build a Trie (prefix tree) that supports these operations: 1. Add a string; 2. Check whether an exact string is stored in the Trie; 3. Check whether at least one stored string begins with a given prefix. Also state the time complexity of insertion, deletion, and lookup. Example Data Constraints The combined number of characters across every string is at most 10^4. Each string contains lowercase letters only. Example Explanation: The exact searches…

Checking your access…