Solved LeetCode program · 745 of 1,000
#0980 · Unique Paths III
Original English source
Keep a shared board holding 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, and -1. Keep a shared visited as a list of 12 zeros. Keep a shared height of 3. Keep a shared width of 4. Keep a shared target of 10. Keep a shared walkable of 11. Keep a shared paths of 0. Set item 0 of visited to 1.
To seek from other (a whole number) with seen (a whole number). If other is less than 0, return. If other is at least 12, return. If item other of board is -1, return. If item other of visited is 1, return. Set item other of visited to 1. Explore from other with seen plus 1. Set item other of visited to 0.
To explore from place (a whole number) with seen (a whole number). If place is target and seen is walkable, add 1 to paths. If place is target, return. The band is place divided by width. The file is place modulo width. If file is more than 0, seek from (place minus 1) with seen. If file is less than width minus 1, seek from (place plus 1) with seen. If band is more than 0, seek from (place minus width) with seen. If band is less than height minus 1, seek from (place plus width) with seen.
Explore from 0 with 1. Show paths.
Expected stdout
2