The TransCompilator

Solved LeetCode program · 614 of 1,000

#0841 · Keys and Rooms

Medium Depth-First Search chunk-13.md

Original English source

Keep a shared edges holding 1, 2, and 3. Keep a shared starts holding 0, 1, 2, and 3. Keep a shared counts holding 1, 1, 1, and 0. Keep a shared queue as an empty list of whole numbers. Keep a shared seen as an empty list of whole numbers.
For every room from 0 to 3.
Place 0 into seen.

Place 0 into queue. Set item 0 of seen to 1. The head is 0. The count is 1.
Repeat while head is less than count.
The node is item head of queue. Add 1 to head.
For every offset from 0 to item node of counts minus 1.
The target is item (item node of starts plus offset) of edges.
If item target of seen is 0.
Set item target of seen to 1. Place target into queue. Add 1 to count.

The reached is 0.
For every room from 0 to 3.
If item room of seen is 1, add 1 to reached.

If reached is 4, show true, otherwise show false.

Open in Playground Browse all 1,000 problems

Expected stdout

true