FastPrepEffective Role Privileges
Problems/Effective Role Privileges

Effective Role Privileges

Snowflake logoSnowflake● MediumFULLTIMEPHONE SCREEN

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

You are given n roles. Role i has a list of direct privileges privileges[i]. You are also given inheritance relations grants, where each pair [u, v] means role v inherits every privilege from role u.

The inheritance graph is a directed acyclic graph. A role's effective privileges are all privileges from its ancestors plus its own direct privileges.

Return the effective privileges for every role. Remove duplicates within each role and return each role's privilege list in lexicographic order.

Function

getEffectivePrivileges(privileges: String[][], grants: int[][]) → String[][]

Examples

Example 1

privileges = [["A"],["B"],["C"]]grants = [[0,1],[1,2]]return = [["A"],["A","B"],["A","B","C"]]

Role 1 inherits role 0, and role 2 inherits both role 1 and role 0 transitively.

Example 2

privileges = [["READ"],["WRITE"],["DEPLOY"],["AUDIT"]]grants = [[0,2],[1,2],[2,3]]return = [["READ"],["WRITE"],["DEPLOY","READ","WRITE"],["AUDIT","DEPLOY","READ","WRITE"]]

Example 3

privileges = [["A","A"],["A"],[]]grants = [[0,1],[1,2]]return = [["A"],["A"],["A"]]

Constraints

  • 1 <= privileges.length <= 2 * 10^5
  • 0 <= grants.length <= 2 * 10^5
  • Each grant is a pair [u, v] with 0 <= u, v < privileges.length.
  • The role inheritance graph is a DAG.
  • Privilege strings are non-empty tokens without spaces.

More Snowflake Phone Screen questions

  • Connect Four from the Last MovePHONE SCREEN · Seen Nov 2026
  • Minimum Edits to a Perfect Binary TreePHONE SCREEN · Seen Nov 2026
  • Configurable Per-Client Token BucketsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Find Valid SET Card TriplesOA · PHONE SCREEN · Seen Nov 2026
  • Minimum Index Distance Between Person and CakeOA · PHONE SCREEN · Seen Nov 2026
  • Minimum N-ary Tree Depth DeletionsOA · PHONE SCREEN · Seen Nov 2026
  • Sum of Binary Tree Boundary NodesOA · PHONE SCREEN · Seen Nov 2026
  • Greedy Person-Cake Matching DistancePHONE SCREEN · Seen Nov 2026
  • Tree Height After Child PromotionPHONE SCREEN · Seen Oct 2026
  • Minimum StackPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Task Build Order and File-Change RerunsVanta · PHONE SCREEN
  • All Halfway Courses Across Course TracksCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Course ScheduleAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Course Schedule Cycle DetectionGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Course ScheduleNykaa · PHONE SCREENNykaa interview questions
  • Course ScheduleBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Delivery Origins and Reachable DestinationsAtlassian · PHONE SCREENAtlassian interview questions
  • Course Schedule FeasibilityTesla · PHONE SCREENTesla interview questions
  • Least-Strong Common DefeaterConfluent · PHONE SCREENConfluent interview questions
  • Course SchedulePlaud · ONSITE INTERVIEW

Snowflake interview experiences

  • Snowflake AI Coding Interview, Experienced Hires: 3 Experiences
All Snowflake interview questionsSee Snowflake hiring insights
Saved
class Solution {
    public String[][] getEffectivePrivileges(String[][] privileges, int[][] grants) {
        // write your code here
    }

}
Checking account…