当前位置:网站首页>[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
边栏推荐
猜你喜欢
![[turn to] MySQL operation practice (I): Keywords & functions](/img/b1/8b843014f365b786e310718f669043.png)
[turn to] MySQL operation practice (I): Keywords & functions

National teacher qualification examination in the first half of 2022

Applet live + e-commerce, if you want to be a new retail e-commerce, use it!

GBase数据库助力湾区数字金融发展

TF-A中的工具介绍

Unity ugui source code graphic

3dsmax snaps to frozen objects

Establish cloth effect in 10 seconds

stm32Cubemx(8):RTC和RTC唤醒中断

嵌入式数据库开发编程(零)
随机推荐
Count sort
Ue4/ue5 illusory engine, material chapter, texture, compression and memory compression and memory
Unity parallax infinite scrolling background
win下一键生成当日的时间戳文件
3dsmax common commands
Simple HelloWorld color change
[转]:Apache Felix Framework配置属性
Research on the value of background repeat of background tiling
Download and use of font icons
A complete attack chain
Cocos create Jiugongge pictures
Lua determines whether the current time is the time of the day
cocos2dx_ Lua card flip
Quick sort summary
Es module and commonjs learning notes
BUUCTF MISC
Judge the position of the monster in the role under unity3d
Embedded database development programming (V) -- DQL
A three-dimensional button
2022/7/1学习总结