Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Trie for Financial Term Search

HardPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Trie for Financial Term Search. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Implement a trie (prefix tree) from scratch that supports efficient insertion, search, and prefix matching for a large dictionary of financial terms.

Implement def financial_trie(operations):, where each operation is ['insert', term], ['search', term], or ['startsWith', prefix]. Return a list of booleans for search and prefix operations in their original order. Terms and prefixes contain lowercase English letters.

An inserted term must be distinguished from a prefix that is not itself a complete term.

Constraints

  • 1 <= operations.length <= 5000
  • Each operation has the form ['insert', text], ['search', text], or ['startsWith', text]
  • 1 <= inserted term length <= 100
  • 0 <= queried text length <= 100
  • Terms and prefixes contain only lowercase English letters
  • Repeated insertions are allowed
  • A search or prefix operation may occur before any insertion

Function Signature

def financial_trie(operations):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output