Order Formula Field Recalculation and Detect Circular References

Last updated: November 29, 2026

Quick Overview

Each field in a table is either a plain value or a formula that references other fields. Return an order in which every formula can be computed, report fields that sit on or depend on a circular reference, and list which fields must be recomputed after one field is edited.

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

0

0

0 solved


Each field in a table is either a plain value or a formula that references other fields. Return an order in which every formula can be computed, report fields that sit on or depend on a circular reference, and list which fields must be recomputed after one field is edited.

Formula fields reference other fields, and the base has to recompute the right ones, in the right order, whenever a cell changes. Interviewers use this to see whether you reach for a topological sort, handle cycles gracefully, and think about incremental work rather than recomputing the world.

What the Interviewer Expects
  • Model fields as a directed dependency graph
  • Use Kahn's algorithm or DFS with colors
  • Report cyclic fields instead of crashing
  • Restrict recomputation to the downstream set of an edit
  • State O(V + E) complexity
Key Topics to Cover
Topological sort
Cycle detection
Dependency graphs
Incremental computation
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 do you reject a formula edit that would introduce a cycle before saving it?
  • How does this change when formulas read through lookups into other tables?
  • How would you parallelize recomputation of independent fields?
  • How would you report the exact cycle path to the 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

Input: {field: [referenced fields]}. Output a valid computation order plus the fields that cannot be computed. Fields downstream of a cycle are also uncomputable, which Kahn's algorithm reports natu...

High-Level Design

Build reverse edges (field to its dependents) and indegrees. Start a queue with fields that reference nothing, pop, append to the order, and decrement dependents. Leftover positive indegrees mark cycl...


Submit Your Answer
Markdown supported

Related Questions