FastPrepInherited Role Permissions
Problems/Inherited Role Permissions

Inherited Role Permissions

Goldman Sachs logoGoldman Sachs● MediumONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamples

Problem statement

Source note: The report does not give a function signature or examples. We left out the reported follow-up about several parents, because its rule for conflicts is not given. This version has a single parent. Our version is about 95% the same as the reported question.

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.

More Goldman Sachs Onsite Interview questions

  • Best Average Student ScorePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Knight Probability in ChessboardONSITE INTERVIEW · Seen Nov 2026
  • Meeting RoomsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Minimum Meeting Rooms Without a Sweep LineONSITE INTERVIEW · Seen Oct 2026
  • First Non-Repeating CharacterPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Root of the Largest TreePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Dungeon HealthONSITE INTERVIEW · Seen Sep 2026
  • Insert, Delete, And Get Random In Constant TimeONSITE INTERVIEW · Seen Sep 2026
  • Least Recently Used CacheONSITE INTERVIEW · Seen Sep 2026
  • Staircase Search In A Sorted MatrixONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • File System Shell CommandsHarvey · ONSITE INTERVIEWHarvey interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Render a Comment HierarchyAmazon · ONSITE INTERVIEW
  • Dictionary Records to an Editable XML TreeSnap Inc. · ONSITE INTERVIEWSnap Inc. interview questions
  • In-Memory File System With Directory SizesCapital One · PHONE SCREEN · ONSITE INTERVIEWCapital One interview questions
  • Workspace File System With Folders and TablesClay · PHONE SCREEN
  • Streaming Step Progress HierarchyThe Allen Institute for AI · PHONE SCREEN
  • Render a Stable Comment HierarchyBobyard · PHONE SCREEN
  • Office Employee HierarchyBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Perfect AND Tree Leaf UpdatesPure Storage · ONSITE INTERVIEWPure Storage interview questions
All Goldman Sachs interview questionsSee Goldman Sachs hiring insights
Saved
class Solution {
    public boolean hasPermission(String[] roles, String[] parents, String[][] allowLists, String[][] denyLists, String role, String permission) {
      // write your code here
    }
}
Checking account…