FastPrepImplement Trie
Problems/Implement Trie

Implement Trie

Optiver logoOptiver● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Optiver intern phone screen in Amsterdam. The report only says to implement a trie. It does not give the API. Our version is about 85% the same as the reported question.

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 a complete word, do is initially only a prefix, and inserting do makes its later search succeed.

Example 2

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

The first search happens before insertion. Afterward, 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, but inserting a word again changes nothing. Searching for cat gives true. The word ca is a prefix of cat, so startsWith is true too.

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 Optiver interview questions

  • Multi-Level Inventory Storage SystemOA · PHONE SCREEN · Seen Aug 2026
  • Client Stock Position OperationsPHONE SCREEN · Seen Aug 2026
  • Implement a FIFO QueuePHONE SCREEN · Seen Nov 2025
  • Overheat Prevention ControllerOA · Seen Nov 2026
  • Power Cell BankOA · Seen Nov 2026
  • Count Straight-Line Word Occurrences in a GridOA · Seen Sep 2026
  • Fastest Average Speed over a Rolling KilometerOA · Seen Sep 2026
  • Proportional Momentum Investment StatisticsOA · Seen Aug 2026
  • Count Bounded Share TransactionsOA · Seen Aug 2026
  • Count Ordered Size SequencesOA · Seen Aug 2026

Similar questions at other companies

  • Design File SystemGoogle · PHONE SCREENGoogle interview questions
  • Prefix Word DictionaryBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Long-ID Store Without HashingAdobe · PHONE SCREENAdobe interview questions
  • Word Dictionary with WildcardsDatadog · PHONE SCREENDatadog interview questions
  • Design a File System with PathsAirbnb · PHONE SCREENAirbnb interview questions
  • Design Search Autocomplete SystemRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Trie and Heap Autocomplete SystemCitadel · PHONE SCREENCitadel interview questions
  • Word Dictionary with Wildcard FindAmazon · ONSITE INTERVIEW
  • Implement a TrieMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Add Word and Suffix SearchAnduril · ONSITE INTERVIEWAnduril interview questions

Optiver interview experiences

  • Optiver SWE Intern OA: CPU Temperature Simulation: 1 Experience
  • Optiver Trading Intern Market-Making Games: 1 Experience
  • Optiver Quant Trader Intern Technical Interview: 1 Experience
  • Optiver SWE Intern System Design Interview: 15 Experiences
All Optiver interview questionsSee Optiver hiring insights
Saved
class Solution {
    public boolean[] trieOperations(String[] operations, String[] values) {
        // Write your code here.
    }

}
Checking account…