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
November 29, 20260
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
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- 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 ProblemsSample 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...