Solved LeetCode program · 799 of 1,000
#1036 · Escape a Large Maze
Original English source
Keep a shared blocked holding 1 and 1000000. Keep a shared visited as an empty list of whole numbers. Keep a shared queue as an empty list of whole numbers. The source is 0. The target is 2. The count is 0. The head is 0.
To open with code (a whole number). The across is code divided by 1000000. The down is code modulo 1000000. If across is less than 0 or across is more than 999999, return. If down is less than 0 or down is more than 999999, return. If blocked contains code, return. If visited contains code, return. Place code into visited. Place code into queue. Add 1 to count.
Open with source.
Repeat while head is less than count and count is at most 20000.
The node is item head of queue. Add 1 to head. The across is node divided by 1000000. The down is node modulo 1000000. If across is more than 0, Open with node minus 1000000. If across is less than 999999, Open with node plus 1000000. If down is more than 0, Open with node minus 1. If down is less than 999999, Open with node plus 1.
The escaped is 0. If visited contains target, set escaped to 1. If count is more than 20000, set escaped to 1. If escaped is 1, show true, otherwise show false.
Expected stdout
false