Evaluate Interdependent Deal Fee and Tax Formulas Safely

Last updated: November 29, 2026

Quick Overview

Given a set of named deal fields, each defined by an arithmetic expression over numbers and other field names (for example tax = taxable * tax_rate), plus input values, parse and evaluate every field in dependency order, reporting cycles and undefined references with a clear error.

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

0

0

0 solved


Given a set of named deal fields, each defined by an arithmetic expression over numbers and other field names (for example tax = taxable * tax_rate), plus input values, parse and evaluate every field in dependency order, reporting cycles and undefined references with a clear error.

Deal structuring in a DMS involves state- and dealer-specific taxes, doc fees, rebates and add-ons whose formulas reference each other, and Tekion's platform has to let configurations change without code deploys. This onsite problem tests parsing with correct precedence, dependency resolution with cycle detection, and exact money arithmetic in one coherent design.

What the Interviewer Expects
  • Writes a tokenizer and a recursive descent parser with correct precedence and unary minus
  • Never uses eval on configuration text
  • Resolves dependencies lazily or topologically, memoizing each field once
  • Detects cycles and reports the cycle path
  • Distinguishes inputs from computed fields and reports undefined names
  • Uses Decimal for money and rounds only at output
Key Topics to Cover
Parsing
Recursive descent
Topological sort
Cycle detection
Decimal arithmetic
Memoization
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 add functions like min, max and round, or a conditional such as a tax cap?
  • How would you validate a dealer's formula set at save time instead of at deal time?
  • When a salesperson changes the rebate, how do you recompute only the affected fields?
  • How would you version formulas so an old signed deal can be recomputed exactly?
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

Rules map field names to expressions with numbers, identifiers, + - * /, parentheses and unary minus. Inputs map names to numbers. Evaluate every rule and return values rounded to cents. Report unde...

High-Level Design

Three stages. Tokenize with a regex into numbers, names and operators. Parse with a small grammar (expr, term, factor) into a tuple AST, which gives * and / higher precedence than + and -. Eva...


Submit Your Answer
Markdown supported

Related Questions