Evaluate Formula Expressions That Reference Record Fields
Last updated: November 29, 2026
Quick Overview
Write an evaluator for a small formula language over a single record: numbers, quoted strings, field references like {Price}, the operators + - * / & and comparisons, parentheses, and functions such as IF, SUM, MAX and CONCAT.
Airtable
November 29, 20260
0
0 solved
Write an evaluator for a small formula language over a single record: numbers, quoted strings, field references like {Price}, the operators + - * / & and comparisons, parentheses, and functions such as IF, SUM, MAX and CONCAT.
Formula fields are central to how Airtable users model their data, and a recursive descent evaluator is a fair 45-minute onsite problem. The interviewer is looking at tokenizing cleanly, getting precedence right, and producing useful errors instead of stack traces.
What the Interviewer Expects
- Separate tokenizing from parsing
- Encode precedence with one function per level
- Resolve field references against the record and treat blanks deliberately
- Support function calls with variable arguments
- Raise clear errors for unknown fields, functions and division by zero
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 compile the formula once and evaluate it for 100,000 records quickly?
- How would you make IF lazy so the untaken branch is never evaluated?
- How would you extract the referenced fields to feed the dependency graph?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Grammar from loosest to tightest: comparison (> < =), additive (+ - &), multiplicative (* /), unary minus, then atoms (number, string, {field}, NAME(args), parenthesized expression). Blank f...
High-Level Design
A regex tokenizer emits typed tokens ending with an end marker. The parser has one method per precedence level, each calling the next tighter level, which makes 2 + 3 * 4 group correctly without a...