From b8af7f3e3804cb4394011e46b10dc79d6b807b9c Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Thu, 27 Jun 2024 22:13:20 +0200 Subject: [PATCH] =?UTF-8?q?go:=20add=20=C2=AB1791.=20Find=20Center=20of=20?= =?UTF-8?q?Star=20Graph=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matej Focko --- go/find-center-of-star-graph.go | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 go/find-center-of-star-graph.go 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 +}