当前位置:网站首页>[to be continued] [depth first search] 547 Number of provinces
[to be continued] [depth first search] 547 Number of provinces
2022-07-05 05:16:00 【lee2813】
One 、 subject
Yes n Cities , Some of them are connected to each other , Others are not connected . If the city a And the city b Direct connection , And the city b And the city c Direct connection , So the city a And the city c Indirectly connected .
Province It's a group of directly or indirectly connected cities , There are no other cities in the group that are not connected .
To give you one n x n Matrix isConnected , among isConnected[i][j] = 1 It means the first one i Two cities and j The two cities are directly connected , and isConnected[i][j] = 0 The two are not directly connected .
Back in the matrix Province The number of .
Example 1:
Input :isConnected = [[1,1,0],[1,1,0],[0,0,1]]
Output :2
Example 2:
Input :isConnected = [[1,0,0],[0,1,0],[0,0,1]]
Output :3
Two 、 Answer key
3、 ... and 、 Code
边栏推荐
猜你喜欢

Django reports an error when connecting to the database. What is the reason

JVM call not used once in ten years

Embedded database development programming (zero)

C语言杂谈1

嵌入式数据库开发编程(零)
![[转]MySQL操作实战(三):表联结](/img/70/20bf9b379ce58761bae9955982a158.png)
[转]MySQL操作实战(三):表联结

Ue4/ue5 illusory engine, material chapter, texture, compression and memory compression and memory

Grail layout and double wing layout

Panel panel of UI

GBase数据库助力湾区数字金融发展
随机推荐
Use the command character to close the keyboard command of the notebook
BUUCTF MISC
What is the agile proportion of PMP Exam? Dispel doubts
服务熔断 Hystrix
Solon Auth 认证框架使用演示(更简单的认证框架)
支持多模多态 GBase 8c数据库持续创新重磅升级
Common technologies of unity
LeetCode之單詞搜索(回溯法求解)
Cocos create Jiugongge pictures
[turn]: OSGi specification in simple terms
[转]MySQL操作实战(三):表联结
Solon Logging 插件的添加器级别控制和日志器的级别控制
Embedded database development programming (V) -- DQL
C language Essay 1
质量体系建设之路的分分合合
Cocos progress bar progresstimer
Common database statements in unity
Insert sort
Unity ugui source code graphic
【ES实战】ES上的native realm安全方式使用