Top Three Search Suggestions as Ichiba Query Counts Change

Last updated: November 29, 2026

Quick Overview

Build an autocomplete structure for Rakuten Ichiba search that records queries with counts and returns the three most frequent queries starting with a given prefix, breaking ties alphabetically, while counts keep increasing.

Rakuten
Coding & Algorithms
Software Engineer
Rakuten
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Build an autocomplete structure for Rakuten Ichiba search that records queries with counts and returns the three most frequent queries starting with a given prefix, breaking ties alphabetically, while counts keep increasing.

Search is the front door to Ichiba, and a lot of Japanese and English queries arrive through the suggestion box. This onsite problem tests trie design with cached top-k lists per node and the reasoning about why the cache stays correct under increments.

What the Interviewer Expects
  • Use a trie keyed by character
  • Cache a top-k list at each node for O(prefix) lookups
  • Update every node on the query's path when a count changes
  • Explain why increments keep the cache exact but decrements do not
  • Discuss memory versus latency
Key Topics to Cover
tries
top-k
caching
autocomplete
string processing
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
  • Counts can decay or be decremented. How do you keep results correct?
  • How would you handle Japanese input where users type kana that should match kanji queries?
  • Shard this for millions of distinct queries and thousands of QPS.
  • How would you personalize suggestions without rebuilding the trie per user?
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(query, times) increases the count for a query. suggest(prefix) returns up to 3 queries with that prefix, ordered by count descending then lexicographically. Suggestions are read far more of...

High-Level Design

A plain trie would require a DFS under the prefix node on every keystroke, which is too slow for short prefixes like a single character. Instead each node stores the best k queries in its subtree. A l...


Submit Your Answer
Markdown supported

Related Questions