当前位置:网站首页>[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
边栏推荐
- 2022/7/1学习总结
- Judge the position of the monster in the role under unity3d
- Stm32cubemx (8): RTC and RTC wake-up interrupt
- 2022/7/2 question summary
- Unity shot tracking object
- [turn]: OSGi specification in simple terms
- [speed pointer] 142 circular linked list II
- [转]: OSGI规范 深入浅出
- Unity connects to the database
- [转]:Apache Felix Framework配置属性
猜你喜欢
随机推荐
Leetcode word search (backtracking method)
[turn]: Apache Felix framework configuration properties
C4D simple cloth (version above R21)
Sixth note
Database under unity
PMP考生,请查收7月PMP考试注意事项
Bucket sort
xftp7与xshell7下载(官网)
[merge array] 88 merge two ordered arrays
服务熔断 Hystrix
Ue4/ue5 illusory engine, material chapter, texture, compression and memory compression and memory
Chinese notes of unit particle system particle effect
Lua wechat avatar URL
[轉]: OSGI規範 深入淺出
The next key of win generates the timestamp file of the current day
远程升级怕截胡?详解FOTA安全升级
发现一个很好的 Solon 框架试手的教学视频(Solon,轻量级应用开发框架)
Basic knowledge points
PR first time
C语言杂谈1




![[转]MySQL操作实战(一):关键字 & 函数](/img/b1/8b843014f365b786e310718f669043.png)



![[interval problem] 435 Non overlapping interval](/img/a3/2911ee72635b93b6430c2efd05ec9a.jpg)
