FastPrepImplement Trie
Problems/Implement Trie

Implement Trie

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report says the first virtual-onsite round asked the candidate to write a trie, but it does not say what the methods looked like. We used the usual three: insert, exact-word search and prefix search. The operations come as a finite array of commands.

Implement the behavior of a prefix tree, also known as a trie.

Process the paired arrays operations and values from left to right:

  • insert: store the word.
  • search: report whether the value is a previously inserted complete word.
  • startsWith: report whether at least one inserted word begins with the value.

Return the boolean results produced by search and startsWith, in operation order. Insert operations produce no result. Repeated insertion of the same word does not change behavior.

Function

trieOperations(operations: String[], values: String[]) → boolean[]

Examples

Example 1

operations = ["insert","search","search","startsWith","insert","search"]values = ["dog","dog","do","do","do","do"]return = [true,false,true,true]

dog is inserted, so searching for it succeeds. do is only a prefix at first, so the search for it fails but startsWith succeeds. After do is inserted, the last search succeeds.

Example 2

operations = ["search","insert","startsWith","search"]values = ["a","abc","ab","abc"]return = [false,true,true]

The first search happens before anything is inserted, so it fails. After abc is inserted, ab is a prefix and abc is a complete word.

Example 3

operations = ["insert","insert","search","startsWith"]values = ["cat","cat","cat","ca"]return = [true,true]

The word cat is inserted twice, which changes nothing. Searching for cat succeeds and ca is a prefix.

Constraints

  • 1 <= operations.length == values.length <= 100000.
  • Each operation is insert, search, or startsWith.
  • 1 <= values[i].length <= 1000.
  • The total length of all values is at most 500000.
  • Every value contains only lowercase English letters.

More Bloomberg LP Onsite Interview questions

  • Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Word Dictionary with Wildcard FindAmazon · ONSITE INTERVIEW
  • Design File SystemGoogle · PHONE SCREENGoogle interview questions
  • Implement a TrieMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Add Word and Suffix SearchAnduril · ONSITE INTERVIEWAnduril interview questions
  • Trie: Add and Search WordsAdobe · ONSITE INTERVIEWAdobe interview questions
  • Implement TrieRoblox · ONSITE INTERVIEWRoblox interview questions
  • In-Memory Directory and File OperationsSquarepoint Capital · ONSITE INTERVIEWSquarepoint Capital interview questions
  • Implement TrieOptiver · PHONE SCREENOptiver interview questions
  • Word Dictionary with WildcardsDatadog · PHONE SCREENDatadog interview questions
  • File System PathsCapital One · ONSITE INTERVIEWCapital One interview questions

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public boolean[] trieOperations(String[] operations, String[] values) {
        // Write your code here.
    }

}
Checking account…