Reported July 2026
Goldman Sachshash table

Inherited Role Permissions

Reported by candidates from Goldman Sachs's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Goldman Sachs OA. Under 2s to a working solution.
Founder's read

The Goldman Sachs OA reported in July 2026 dresses up a simple idea in role-and-permission language. Strip it down and it's a linked-list walk: start at a role, climb parent pointers, and stop at the first role that mentions the permission. If you've got an invite in your inbox, this is a problem you can finish fast if you build the right lookup first. The trap is in the parallel arrays, not the logic. If your head goes blank on the setup mid-assessment, StealthCoder runs invisibly on your desktop as a safety net and gives you the solution while you keep typing.

The problem

A role may inherit from one parent role. Each role has an allow list and a deny list of permission names. A child role inherits decisions from its ancestors, but the nearest explicit decision overrides every decision higher in the hierarchy.
For the requested role and permission:
Starting at role, walk toward the root.
If the current role explicitly denies the permission, return false.
If the current role explicitly allows the permission, return true.
If no role in the chain mentions the permission, return false.
The arrays roles, parents, allowLists, and denyLists are aligned by index. A root role has the empty string as its parent. A role never contains the same permission in both of its own lists.

Function
hasPermission(roles: String[], parents: String[], allowLists: String[][], denyLists: String[][], role: String, permission: String) → boolean

Examples
Example 1
roles = ["employee","engineer","intern"]
parents = ["","employee","engineer"]
allowLists = [["read"],["deploy"],[]]
denyLists = [[],[],["deploy"]]
role = "intern"
permission = "deploy"
return = false
The intern's explicit deny overrides the engineer's inherited allow.
Example 2
roles = ["employee","engineer","intern"]
parents = ["","employee","engineer"]
allowLists = [["read"],["deploy"],[]]
denyLists = [[],[],["deploy"]]
role = "intern"
permission = "read"
return = true
Neither intern nor engineer mentions read, so the permission is inherited from employee.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is to turn the aligned arrays into hash maps once. Map each role name to its parent, its allow set, and its deny set. Then loop from the requested role: if the deny set contains the permission, return false. If the allow set contains it, return true. Otherwise move to the parent. Stop when the parent is the empty string and return false. Check deny before allow, though the problem guarantees a role never lists a permission in both. The common pitfall is scanning the arrays by index on every step, which turns the climb into a quadratic mess. Another is forgetting the default of false when nothing mentions the permission. Also handle a role missing from the map without crashing. Time is O(n) to build and O(depth) to query. If you freeze on the map setup during the live OA, StealthCoder is the hedge that shows the clean version.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Inherited Role Permissions cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Goldman Sachs's OA.

Goldman Sachs reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Inherited Role Permissions FAQ

What's the real trick in the Inherited Role Permissions problem?+

Nearest decision wins, so you walk from the requested role up through parents and stop at the first role that explicitly allows or denies the permission. Build a name-to-index or name-to-sets map first so each hop is a constant-time lookup instead of an array scan.

How hard is this Goldman Sachs OA question really?+

Easy to medium. There's no fancy algorithm, just careful modeling of the parallel arrays and the override rule. Most people who miss it stumble on the default false case or on scanning arrays repeatedly. Write it cleanly and it's a ten-minute problem.

Should I convert the allow and deny lists to sets?+

Yes. Turn each role's lists into hash sets keyed by role name. Membership checks become O(1), and the loop only touches roles on the ancestor chain. With plain lists you'd still pass small inputs but risk slowing down on larger hidden tests.

What edge cases should I test before submitting?+

Test a permission no role mentions, which must return false. Test a root role with the empty-string parent. Test a child that denies what its parent allows, and a child that allows what its parent denies. Also test the requested role being the root itself.

How do I prepare for this in 48 hours?+

Practice walking parent pointers with hash maps, since this reduces to an ancestor lookup. Write this one from scratch twice, focusing on building the maps from aligned arrays. Then do a couple of tree-climb problems so the loop and termination condition feel automatic.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Goldman Sachs.

OA at Goldman Sachs?
Invisible during screen share
Get it