Find the Approval Chain for a Software Purchase Request

Last updated: November 29, 2026

Quick Overview

Given each employee's manager and each approver's spending limit, return the ordered list of managers a purchase request must pass through, stopping at the first manager whose limit covers the amount. Raise an error if no one can approve it or if the org chart contains a cycle.

Moveworks
Coding & Algorithms
Software Engineer
Moveworks
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Easy

0

0

0 solved


Given each employee's manager and each approver's spending limit, return the ordered list of managers a purchase request must pass through, stopping at the first manager whose limit covers the amount. Raise an error if no one can approve it or if the org chart contains a cycle.

Agentic assistants that provision software or approve expenses must route requests to the right approvers pulled from an HRIS like Workday. The interviewer wants a correct walk up a parent-pointer tree and checks whether you defend against dirty real-world data such as cycles and missing managers.

What the Interviewer Expects
  • Models the org chart as a parent-pointer map
  • Stops at the first sufficient approver, not the top of the tree
  • Detects cycles with a visited set
  • Distinguishes 'no approver' from 'bad data' errors
  • States complexity in terms of chain depth
Key Topics to Cover
Tree traversal
Parent pointers
Cycle detection
Data validation
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
  • Some approvers are on leave and have a delegate; how does the walk change?
  • Requests over $50k also need a finance approver regardless of chain; how would you model policy rules?
  • How would you cache chains for thousands of employees when the org chart changes nightly?
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

Inputs: requester, amount, manager_of (employee to manager or None at the top), limit_of (approver to max amount). The requester never approves their own request. Output: approvers in order, t...

High-Level Design

Walk parent pointers starting at the requester's manager, appending each manager to the chain. Keep a seen set seeded with the requester; revisiting anyone means the HR data has a loop, which happen...


Submit Your Answer
Markdown supported

Related Questions