当前位置:网站首页>[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
边栏推荐
- [allocation problem] 135 Distribute candy
- Optimization scheme of win10 virtual machine cluster
- 2022/7/1學習總結
- Unity sends messages and blocks indecent words
- stm32Cubemx(8):RTC和RTC唤醒中断
- What is the agile proportion of PMP Exam? Dispel doubts
- Lua GBK and UTF8 turn to each other
- UE4/UE5 虚幻引擎,材质篇,纹理,Compression and Memory压缩和内存
- Ue4/ue5 illusory engine, material part (III), material optimization at different distances
- 2022/7/1 learning summary
猜你喜欢
UE fantasy engine, project structure
Unity3d learning notes
2022/7/2 question summary
The present is a gift from heaven -- a film review of the journey of the soul
Unity check whether the two objects have obstacles by ray
Magnifying glass effect
Unity find the coordinates of a point on the circle
Learning notes of "hands on learning in depth"
Data is stored in the form of table
Embedded database development programming (zero)
随机推荐
Sixth note
Unity get component
Use the command character to close the keyboard command of the notebook
Solon 框架如何方便获取每个请求的响应时间?
Es module and commonjs learning notes
Heap sort summary
[interval problem] 435 Non overlapping interval
支持多模多态 GBase 8c数据库持续创新重磅升级
Chinese notes of unit particle system particle effect
[转]MySQL操作实战(三):表联结
[allocation problem] 135 Distribute candy
Cocos create Jiugongge pictures
2022/7/1学习总结
UE4/UE5 虚幻引擎,材质篇,纹理,Compression and Memory压缩和内存
django连接数据库报错,这是什么原因
Grail layout and double wing layout
Development error notes
Ue4/ue5 illusory engine, material part (III), material optimization at different distances
Programmers' experience of delivering takeout
Lua GBK and UTF8 turn to each other