diff --git a/go/find-center-of-star-graph.go b/go/find-center-of-star-graph.go new file mode 100644 index 0000000..f29c72f --- /dev/null +++ b/go/find-center-of-star-graph.go @@ -0,0 +1,11 @@ +package main + +func findCenter(edges [][]int) int { + u, v := edges[0][0], edges[0][1] + s, t := edges[1][0], edges[1][1] + + if u == s || u == t { + return u + } + return v +}