Keys and Rooms
Updated
Problem statement
Room zero is initially unlocked. Each room contains keys to other rooms. Return whether all rooms can be visited.
Function
canVisitAllRooms(rooms: List<List<Integer>>) → booleanExamples
Example 1
rooms = [[1],[2],[3],[]]return = trueKeys discovered in order unlock rooms 1, 2, and 3.
Constraints
1 <= rooms.length <= 10000- Every key is a valid room index.
More Atlassian Online Assessment questions
- Planning ProductionOA · Seen Feb 2025
- K-Means ClusteringOA · Seen Feb 2025
- Minimum Sorted Erasure OperationsOA · Seen Jun 2024
- Count Analogous ArraysOA · Seen Mar 2024
- Get Maximum ScoreOA · Seen Mar 2024
- Better Compression 🦀OA · Seen Mar 2024
- Romanizer 🐡OA · Seen Mar 2024
- Flower Bouquets 💐OA · Seen Mar 2024
- Binary Search Tree IteratorOA · Seen Nov 2023
- Binary Tree Level Order TraversalOA · Seen Nov 2023
Similar questions at other companies
- Base Unit ConversionsAdobe · OAAdobe interview questions
- Part 1: The Narrowest KeyScale AI · OAScale AI interview questions
- Minimum Unreachable WarehousesVisa · OAVisa interview questions
- Minimum Cleaning Robot RunsHSBC · OAHSBC interview questions
- Supply Path OptimizationInMobi · OAInMobi interview questions
- Number of IslandsGoldman Sachs · OA · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
- Maximum Data Transfer TimeMicrosoft · OAMicrosoft interview questions
- Validate a DFS Traversal OrderRippling · OARippling interview questions
- Converging Maze: Largest Sum CycleJuspay · OA
- Maximum Damage PatchGecko Robotics · OA · PHONE SCREEN