PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates reasoning about access-control and transitive relationships, testing skills in graph modeling, reachability, and set operations within permission hierarchies.

  • medium
  • Verkada
  • Coding & Algorithms
  • Software Engineer

Find user who can access every camera

Company: Verkada

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You are given permissions data describing which **users** and **groups** have ownership access to which **cameras**, and which entities are members of which **groups**. Each permission record is a triple: - `(entity_id, relationship, object_id)` Where: - `relationship` is one of: - `"camera_owner"`: `entity_id` (a user or a group) directly has access to `object_id` (a camera). - `"group_member"`: `entity_id` (a user or a group) is a member of `object_id` (a group). ### Access rules - A user can access a camera if they: - own it directly (`user -> camera_owner -> camera`), or - are a member of a group that owns it, including through **nested group membership**. - Groups can be nested to multiple levels. - There are **no cycles** in group membership. - Users can be members of multiple groups. - Some users may not belong to any group. ### Task Return the ID of the **single Admin user**—defined as the *only* user who can access **every camera referenced anywhere in the data** (i.e., every `camera_*` appearing as the `object_id` of a `"camera_owner"` record). It is guaranteed that **exactly one** such admin user exists. ### Input - `permissionsData`: an array/list of triples `(entity_id, relationship, object_id)`. - `entity_id` is a string like `"user_1"` or `"group_2"`. - `object_id` is a string like `"camera_3"` (for `camera_owner`) or `"group_7"` (for `group_member`). ### Output - A string user ID (e.g., `"user_1"`) for the admin user. ### Example Given: - `("user_1", "camera_owner", "camera_1")` - `("user_1", "group_member", "group_1")` - `("group_1", "camera_owner", "camera_2")` - `("group_1", "group_member", "group_2")` - `("group_2", "camera_owner", "camera_3")` Then `user_1` can access `camera_1` directly, `camera_2` via `group_1`, and `camera_3` via `group_1 -> group_2`, so `user_1` would be the admin in this dataset. ### Constraints - Must run within typical interview-scale limits (e.g., a few seconds).

Quick Answer: This question evaluates reasoning about access-control and transitive relationships, testing skills in graph modeling, reachability, and set operations within permission hierarchies.

You are given a list of permission triples (entity_id, relationship, object_id). A record with relationship 'camera_owner' means the entity directly has access to a camera. A record with relationship 'group_member' means the entity belongs to a group. Entities can be users or groups, and groups can be nested to multiple levels without cycles. A user can access a camera if they own it directly or inherit access through any chain of group memberships. Return the ID of the single admin user: the only user who can access every camera that appears as the object_id of any 'camera_owner' record.

Constraints

  • 1 <= len(permissionsData) <= 20000
  • At least one 'camera_owner' record exists.
  • The group-membership graph is acyclic.
  • Duplicate permission records may appear.
  • Exactly one user can access all referenced cameras.

Examples

Input: [('user_1', 'camera_owner', 'camera_1'), ('user_1', 'group_member', 'group_1'), ('group_1', 'camera_owner', 'camera_2'), ('group_1', 'group_member', 'group_2'), ('group_2', 'camera_owner', 'camera_3'), ('user_2', 'group_member', 'group_1')]

Expected Output: 'user_1'

Explanation: user_1 has camera_1 directly, camera_2 through group_1, and camera_3 through group_1 -> group_2. user_2 only gets camera_2 and camera_3.

Input: [('user_9', 'camera_owner', 'camera_42')]

Expected Output: 'user_9'

Explanation: This is the single-record edge case. The only referenced camera is camera_42, and user_9 owns it directly.

Input: [('group_1', 'camera_owner', 'camera_1'), ('group_2', 'camera_owner', 'camera_2'), ('user_1', 'group_member', 'group_1'), ('user_1', 'group_member', 'group_2'), ('user_2', 'group_member', 'group_1'), ('user_3', 'group_member', 'group_2')]

Expected Output: 'user_1'

Explanation: user_1 combines access from two groups and reaches both cameras. user_2 and user_3 each reach only one.

Input: [('group_3', 'camera_owner', 'camera_4'), ('group_2', 'group_member', 'group_3'), ('group_1', 'group_member', 'group_2'), ('user_7', 'group_member', 'group_1'), ('user_7', 'camera_owner', 'camera_1'), ('group_1', 'camera_owner', 'camera_2'), ('group_2', 'camera_owner', 'camera_3'), ('user_8', 'group_member', 'group_2')]

Expected Output: 'user_7'

Explanation: user_7 gets camera_1 directly and inherits camera_2, camera_3, and camera_4 through group_1 -> group_2 -> group_3. user_8 only gets camera_3 and camera_4.

Input: [('group_1', 'camera_owner', 'camera_1'), ('group_1', 'camera_owner', 'camera_1'), ('group_2', 'camera_owner', 'camera_2'), ('group_1', 'group_member', 'group_2'), ('user_1', 'group_member', 'group_1'), ('user_1', 'group_member', 'group_1'), ('user_2', 'camera_owner', 'camera_1')]

Expected Output: 'user_1'

Explanation: Duplicate records should not change the result. user_1 gets camera_1 from group_1 and camera_2 through group_1 -> group_2, while user_2 only has camera_1.

Hints

  1. Think of each entity as depending on the groups it belongs to. Its full access is its direct cameras plus all cameras available to those parent groups.
  2. Because the group graph has no cycles, DFS with memoization (or topological DP) can compute inherited access efficiently without recomputing the same group many times.
Last updated: Apr 26, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Merge Sorted Arrays In Place - Verkada (medium)
  • Find and Merge Camera Alert Intervals - Verkada (hard)
  • Implement LRU and LFU caches - Verkada (medium)
  • Validate a 9×9 grid under constraints - Verkada (medium)
  • Implement a recency cache and min-coins DP - Verkada (medium)