Detect Segregation of Duties Conflicts Through Inherited Roles

Last updated: November 29, 2026

Quick Overview

Users are granted roles, roles can inherit other roles, and each role grants permissions. Given a list of conflicting permission pairs (for example create vendor and release payment), return every user who effectively holds both sides of a conflict, and fail clearly if role inheritance has a cycle.

PwC
Coding & Algorithms
Software Engineer
PwC
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Users are granted roles, roles can inherit other roles, and each role grants permissions. Given a list of conflicting permission pairs (for example create vendor and release payment), return every user who effectively holds both sides of a conflict, and fail clearly if role inheritance has a cycle.

Access reviews and segregation of duties analysis are a core part of PwC's IT audit and risk consulting work on ERP systems, where composite roles hide toxic permission combinations. The interviewer checks graph traversal with memoization, cycle detection, and output that an auditor can trust.

What the Interviewer Expects
  • Model roles as a directed graph and compute effective permissions with DFS
  • Memoize resolved roles so shared sub-roles are computed once
  • Detect and report cycles instead of recursing forever
  • Check each conflict pair against the user's effective permission set
  • Return deterministic, sorted output
Key Topics to Cover
Graph DFS
Memoization
Cycle detection
Set operations
Access control
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 would you also report which role path granted each conflicting permission?
  • How would you handle mitigating controls that waive a conflict for a specific user?
  • Role graphs can have tens of thousands of roles; would you switch to an iterative DFS?
  • How would you find the smallest set of role removals that clears a 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

Inputs: user_roles (user to directly assigned roles), role_children (composite role to inherited roles), role_perms (role to direct permissions), conflicts (permission pairs). Output: for each...

High-Level Design

Effective permissions of a role are its direct permissions unioned with those of every role it inherits. Compute this with DFS and three-color marking: unvisited, visiting, done. Hitting a visiting no...


Submit Your Answer
Markdown supported

Related Questions