Rank Watson Assistant Intent Suggestions by Prefix and Frequency

Last updated: November 29, 2026

Quick Overview

Build a structure over intent names with usage counts that returns the top three intents for any typed prefix, ordered by count descending and then alphabetically, and supports incrementing counts.

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

0

0

0 solved


Build a structure over intent names with usage counts that returns the top three intents for any typed prefix, ordered by count descending and then alphabetically, and supports incrementing counts.

watsonx Assistant (formerly Watson Assistant) authoring tools autocomplete intent and entity names as builders type. A trie with cached top results per node is the expected answer in this IBM onsite question, and the interviewer probes the trade-off between update cost and query cost.

What the Interviewer Expects
  • Use a trie keyed by character
  • Cache the top three at each node for O(prefix) queries
  • Update caches along the path when a count changes
  • Define the tie-break order explicitly
  • Compare with sorting matches at query time
Key Topics to Cover
trie
prefix search
top-k
caching
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
  • How would you support deleting an intent?
  • What if k is large or varies per request?
  • How would you handle typos in the prefix?
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

add(name, count=1) inserts or increments an intent. suggest(prefix) returns up to three names starting with prefix, sorted by count descending, then name ascending. Expect far more queries (ever...

High-Level Design

Each trie node keeps a children map and a small list top of the best three names in its subtree. On add, update the global count, then walk the path from root to the name's end node and, at each n...


Submit Your Answer
Markdown supported