urlname
type
Post
password
SyncToConfluence
category
Leetcode
date
Apr 13, 2024
slug
01HVBVX2DEPKYTB0DPBYVQ2VSX
icon
Button
catalog
summary
tags
Algorithm
DAG
cover
Status
BusyTime
Status 1
status
Published
题目链接
关键词
- 有向无环图
- 图
解析
- 从题意分析,如果a胜过b,表示有一条边从a出发,连向b,此时a的出度+1,b的入读+1
- 从出度和入度的角度出发,对于冠军,其入度一定为0,因为没有人能胜过冠军
- 同时,为了确保冠军的唯一性,如果有多个入度为0的点,就直接返回-1
代码
- Author:CoderWdd
- URL:https://www.wuinsights.top//article/01HVBVX2DEPKYTB0DPBYVQ2VSX
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!
Relate Posts
