Leetcode Note: Go - Find Center of Star Graph

Find Center of Star Graph - LeetCode
https://leetcode.com/problems/find-center-of-star-graph/

  • Go 言語で取り組んだメモ

回答

[Go/JS] Check 2 Edges O(1) O(1) - Find Center of Star Graph - LeetCode
https://leetcode.com/problems/find-center-of-star-graph/solutions/1108420/go-js-check-2-edges-o-1-o-1/

func findCenter(edges [][]int) int {
    if edges[0][0] == edges[1][0] || edges[0][0] == edges[1][1] {
        return edges[0][0]
    }
    return edges[0][1]
}