Payee Autocomplete Ranked by How Often Members Pay Them

Last updated: November 29, 2026

Quick Overview

Build an autocomplete for a bill pay screen: record payments to payee names, and for any typed prefix return the top three payees by payment count, breaking ties alphabetically, with case-insensitive matching.

SoFi
Coding & Algorithms
Software Engineer
SoFi
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Build an autocomplete for a bill pay screen: record payments to payee names, and for any typed prefix return the top three payees by payment count, breaking ties alphabetically, with case-insensitive matching.

SoFi's money app lets members send payments and pay bills, and fast suggestions from a member's own history make that flow smoother. The interviewer checks trie construction, a strategy for top-k per prefix, and a correctness argument for maintaining cached top lists on update.

What the Interviewer Expects
  • Implements a trie keyed by lowercase characters
  • Caches a top-3 list at each node so queries cost O(prefix length)
  • Argues why updating only the paid name's path keeps caches correct
  • Applies count-desc then name-asc ranking consistently
  • Discusses memory trade-offs versus DFS at query time
Key Topics to Cover
tries
prefix search
top-k caching
autocomplete
ranking
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • What changes if payees can be deleted or counts can decrease?
  • How would you rank by recency as well as frequency?
  • How would you support typo tolerance, for example 'cmcast' finding Comcast?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

record_payment(payee) increments that payee's count. suggest(prefix) returns at most 3 names, highest count first, ties alphabetical, case-insensitive. An empty prefix returns nothing (the UI show...

High-Level Design

Option A: trie plus DFS from the prefix node at query time, then sort. Simple, but a short prefix like 'c' scans much of the trie. Option B (chosen): each trie node caches its top 3 names. On a paymen...


Submit Your Answer
Markdown supported

Related Questions