当前位置:网站首页>LeetCode Algorithm 997. Find the town judge
LeetCode Algorithm 997. Find the town judge
2022-06-12 01:42:00 【Alex_ 12 hours a day 6 days a week】
Topic link :997. Find the judge in town
Ideas
Algorithm : Count
data structure : chart
Ideas : Count the in and out degrees of each node , The degree of n-1, The degree of 0 The node of is the town judge .
Code
Python
from collections import Counter
from typing import List
class Solution:
def findJudge(self, n: int, trust: List[List[int]]) -> int:
ans, in_degree, out_degree = -1, Counter(), Counter()
for (start, end) in trust:
in_degree[end] += 1
out_degree[start] += 1
for i in range(1, n + 1):
if in_degree[i] == n - 1 and out_degree[i] == 0:
ans = i
return ans
边栏推荐
- 华为,这也太强了吧..
- The role of MOV ah, 4CH int 21
- Jvm: thread context classloader
- Several visualization methods of point cloud 3D object detection results (second, pointpillars, pointrcnn)
- "Xilin chain" of Southwest Forestry University passed the functional test of Electronic Standards Institute of the Ministry of industry and information technology | FISCO bcos case
- In depth description of Weibull distribution (2) meaning of parameters and formulas
- Advanced data storage
- How to buy children's serious illness insurance, what to pay attention to and how to choose products
- Matlab 基础应用02 wind 股票数据介绍和使用案例:
- [project training] wechat official account template message push
猜你喜欢

redis集群(cluster)+哨兵模式+主从(replicas)

给你一个项目,你将如何开展性能测试工作?

MySQL实训报告【带源码】

Yixin Huachen talks about how to do a good job in customer master data management

华为联运游戏或应用审核驳回:应用检测到支付serviceCatalog:X6

Why should a redis cluster use a reverse proxy? Just read this one

Go language learning summary (7) -- Dachang go programming specification summary
![MySQL training report [with source code]](/img/c2/46bdc2f8c522d2c8881e532b6f3f49.png)
MySQL training report [with source code]

马尔可夫网络 与 条件随机场

The road of global evolution of vivo global mall -- multilingual solution
随机推荐
LeetCode Algorithm 997. 找到小镇的法官
【项目实训】jwt
Websocket server practice
“還是學一門技術更保險!”杭州校區小哥哥轉行軟件測試,喜提10K+雙休!
Yixin Huachen talks about how to do a good job in customer master data management
马尔可夫网络 与 条件随机场
TIOBE - 2022年6月编程语言排行
Recursive and non recursive transformation
The CSV used for JMeter performance test is bullshit
Operation of simulated examination platform of diazotization process examination question bank in 2022
[从零开始学习FPGA编程-20]:快速入门篇 - 操作步骤4-2-Altera Quartus II工具的快速使用(modelSim联合仿真、程序下载到Altera开发板)
Software engineering course: Chapter 2 software problem definition and feasibility analysis after class exercises
What is the digital twin of Yixin Huachen and what is its application value?
A summary of the interface automation test problems most easily encountered
Educational knowledge and ability test questions of primary and secondary school educational endowment examination in the second half of 2019 (middle school) - subjective questions
Interviewer: do you understand redis' shared object pool?
博文推荐|BookKeeper - Apache Pulsar 高可用 / 强一致 / 低延迟的存储实现
New knowledge: monkey improved app crawler
Data system provider Jidao technology joins dragon lizard community
Set up NFT blind box mall system | customized development of NFT mall software