List Every Approval Path in a Credit Policy Decision Tree

Last updated: November 29, 2026

Quick Overview

A credit policy is a binary tree whose internal nodes hold rules and whose leaves say APPROVE or DECLINE; the right child is taken when the rule is true. Return every root-to-leaf path that ends in APPROVE as a list of (rule, outcome) pairs.

Upstart
Coding & Algorithms
Software Engineer
Upstart
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


A credit policy is a binary tree whose internal nodes hold rules and whose leaves say APPROVE or DECLINE; the right child is taken when the rule is true. Return every root-to-leaf path that ends in APPROVE as a list of (rule, outcome) pairs.

Before Upstart's models, lenders encoded credit policy as hand-written rule trees, and Upstart still layers policy rules (eligibility, state regulations) around model scores. The phone screen uses this to check basic tree recursion, path backtracking, and clean output for compliance reviewers.

What the Interviewer Expects
  • Use DFS with an explicit path list
  • Record whether each rule was true or false
  • Copy the path when a leaf is reached
  • Undo path changes on the way back up
  • Handle a single-leaf tree
Key Topics to Cover
binary trees
DFS
backtracking
recursion
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
  • Return the path as a single boolean expression string.
  • Two different paths may be logically equivalent. How would you simplify them?
  • How would you do this iteratively for a very deep tree?
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 internal node has two children: left means the rule evaluated false, right means true. Leaves have no children. Output the APPROVE paths in left-to-right order. A tree that is only an APPROVE lea...

High-Level Design

Depth-first search carries a mutable path. At an internal node, push (rule, False) and go left, then flip the last entry to (rule, True) and go right, then pop. At a leaf, append a copy of the pat...


Submit Your Answer
Markdown supported