Resolve Effective Users Through Cyclic Nested Group Membership

Last updated: November 29, 2026

Quick Overview

Groups contain users ('u:name') and other groups ('g:name'), and nesting may form cycles. For every group, return the sorted list of users who are effective members through any depth of nesting, computing shared subgroups only once.

Okta
Coding & Algorithms
Software Engineer
Okta
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Groups contain users ('u:name') and other groups ('g:name'), and nesting may form cycles. For every group, return the sorted list of users who are effective members through any depth of nesting, computing shared subgroups only once.

Okta customers sync nested groups from Active Directory and assign apps to groups, so the platform must flatten nesting to decide who gets access, and real directories do contain membership cycles. A hard onsite round uses this to see whether you go beyond a naive per-group DFS to strongly connected components and dynamic programming over the condensed DAG.

What the Interviewer Expects
  • Notes that naive DFS from each group is O(G * (G + E)) and repeats work on shared subgroups
  • Handles cycles explicitly, recognizing that all groups in a cycle share the same effective members
  • Uses Tarjan or Kosaraju to find strongly connected components
  • Combines user sets over the condensation in reverse topological order
  • Writes an iterative DFS or discusses recursion depth for deep nesting
  • Handles groups referenced but never defined
Key Topics to Cover
strongly connected components
Tarjan algorithm
DAG dynamic programming
cycle handling
graph traversal
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
  • A user is added to one deep group. How do you update effective membership incrementally?
  • User sets are huge. How would bitsets or a lazy membership check change the trade-off?
  • How would you answer only 'is user X in group Y' without materializing everything?
  • How would you report the cycles to an admin as a lint warning?
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

Input: groups: dict[str, list[str]]. An edge A -> B means group B is nested in A, so B's users are A's users too. Cycles are allowed (backend contains oncall, oncall contains backend). Groups ment...

High-Level Design

Inside a cycle, every group can reach every other, so they have identical effective members. Collapse each strongly connected component into one node; the result is a DAG. Tarjan's algorithm emits...


Submit Your Answer
Markdown supported