Skip to content

Commit

Permalink
add sol
Browse files Browse the repository at this point in the history
  • Loading branch information
ductnn committed Dec 15, 2023
1 parent 18e8fc7 commit 60033b4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions leetcode/1436.DestinationCity/destinationCity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"fmt"
)

func destCity(paths [][]string) string {
s := map[string]bool{}
for _, p := range paths {
s[p[0]] = true
}
for _, p := range paths {
if !s[p[1]] {
return p[1]
}
}
return ""
}

func main() {
paths := [][]string{{"London", "New York"}, {"New York", "Lima"}, {"Lima", "Sao Paulo"}}
fmt.Println(destCity(paths))
}

0 comments on commit 60033b4

Please sign in to comment.