1
0
Fork 0

Run gofmt on code

main
Bill Ewanick 2023-11-15 17:21:22 -05:00
parent 454937e2b8
commit f9192bc541
2 changed files with 15 additions and 14 deletions

View File

@ -80,6 +80,7 @@
clean clean
go go
gofumpt
]); ]);
shellHook = '' shellHook = ''

View File

@ -9,16 +9,16 @@ func main() {
func canVisitAllRooms(rooms [][]int) bool { func canVisitAllRooms(rooms [][]int) bool {
if len(rooms) > 0 && len(rooms[0]) == 0 { if len(rooms) > 0 && len(rooms[0]) == 0 {
return false return false
} }
keys := getAllKeys(0, make(map[int]struct{}), rooms) keys := getAllKeys(0, make(map[int]struct{}), rooms)
keys[0] = struct{}{} keys[0] = struct{}{}
for i := 0; i < len(rooms); i++ { for i := 0; i < len(rooms); i++ {
if _, ok := keys[i]; !ok { if _, ok := keys[i]; !ok {
return false return false
} }
} }
return true return true
} }
@ -27,14 +27,14 @@ func getAllKeys(index int, seen map[int]struct{}, rooms [][]int) map[int]struct{
keys := map[int]struct{}{} keys := map[int]struct{}{}
for j := 0; j < len(rooms[index]); j++ { for j := 0; j < len(rooms[index]); j++ {
if _, ok := keys[rooms[index][j]]; ok { if _, ok := keys[rooms[index][j]]; ok {
continue continue
} }
keys[rooms[index][j]] = struct{}{} keys[rooms[index][j]] = struct{}{}
insideKeys := getAllKeys(j, keys, rooms) insideKeys := getAllKeys(j, keys, rooms)
for k := range insideKeys { for k := range insideKeys {
keys[k] = struct{}{} keys[k] = struct{}{}
} }
} }
return keys return keys