1
2
3
4
5
6
7
8
|
class Solution:
def findCenter(self, edges: List[List[int]]) -> int:
ans=0
if edges[0][0]==edges[1][0]: ans=edges[0][0]
if edges[0][0]==edges[1][1]: ans=edges[0][0]
if edges[0][1]==edges[1][0]: ans=edges[0][1]
if edges[0][1]==edges[1][1]: ans=edges[0][1]
return ans
|
cs |
모든 노드들에 대해서 확인 해볼 필요 없이 처음 두 노드에만 확인하면 됩니다.
반응형
'python-algorithm' 카테고리의 다른 글
Leetcode 1913. Maximum Product Difference Between Two Pairs (0) | 2021.07.16 |
---|---|
Leetcode 1486. XOR Operation in an Array (0) | 2021.07.16 |
Leetcode 1221. Split a String in Balanced Strings (0) | 2021.07.16 |
Leetcode 1773. Count Items Matching a Rule (0) | 2021.07.16 |
Leetcode 1678. Goal Parser Interpretation (0) | 2021.07.16 |
댓글