Parse Bid Commands From Noisy Livestream Chat Messages
Last updated: November 29, 2026
Quick Overview
Livestream chat lets buyers type bids such as "!bid 25", "$25.50", or just "30". Given (user, message) pairs, extract valid bids as integer cents and ignore every message that is not a well-formed positive bid.
Whatnot
November 29, 20260
0
0 solved
Livestream chat lets buyers type bids such as "!bid 25", "$25.50", or just "30". Given (user, message) pairs, extract valid bids as integer cents and ignore every message that is not a well-formed positive bid.
Whatnot chat is fast and messy during a show, and any feature that reads intent from chat has to be strict about what counts as a bid. This screen checks careful string parsing, money handling without floats, and good test cases.
What the Interviewer Expects
- Define the accepted grammar before coding
- Convert to integer cents rather than floats
- Reject negatives, zero, extra text, and too many decimals
- Trim whitespace and ignore case on the command word
- List concrete test messages
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you support "25k" or comma separators like "1,000"?
- How would you avoid accidental bids from someone just talking about a price?
- How would this parser change for non-US currencies?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Accepted forms: an optional !bid or bid command (any case) followed by whitespace, an optional $, one to six digits, and an optional decimal part of one or two digits. Surrounding whitespace is ...
High-Level Design
A single anchored regular expression captures the dollars and fraction. The fraction is right-padded to two digits so .5 means 50 cents. Integer arithmetic avoids 0.1 + 0.2 style errors. A hand-wr...