Prune a Feature Query Plan to Requested Outputs

Last updated: November 29, 2026

Quick Overview

Given resolvers with declared inputs and outputs, the features a caller supplies, and the features it asks for, return only the resolvers that must run, in a valid execution order, and explain any feature that cannot be resolved.

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

0

0

0 solved


Given resolvers with declared inputs and outputs, the features a caller supplies, and the features it asks for, return only the resolvers that must run, in a valid execution order, and explain any feature that cannot be resolved.

A Chalk deployment can define thousands of features, but an online query for a fraud score needs a small slice, and running anything extra burns latency and source calls. This tests backward reachability over a dependency graph, short-circuiting on supplied inputs, and actionable error messages.

What the Interviewer Expects
  • Walks backward from requested outputs rather than forward from inputs
  • Stops at features the caller already supplied, skipping their resolvers
  • Emits resolvers in post-order so dependencies run first, each exactly once
  • Detects cycles with a visiting state
  • Produces an error that names the missing feature and the chain that needed it
Key Topics to Cover
DFS
dependency graph
query pruning
post-order traversal
cycle detection
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
  • If a feature has two possible resolvers with different costs, how would you choose the cheapest valid plan?
  • How would you turn the ordered list into parallel stages?
  • The recursion can overflow on very deep chains. How would you make it iterative?
  • How would you cache plans across requests that ask for the same outputs?
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

Each feature has at most one producing resolver. Supplied features are never recomputed. Output is the list of resolver names to execute, dependencies before dependents, with no duplicates and nothing...

High-Level Design

This is a DFS from each requested feature. For a feature: if supplied, stop. Otherwise find its resolver; if already scheduled, stop; if currently on the stack, it is a cycle; else recurse into the re...


Submit Your Answer
Markdown supported

Related Questions