当前位置:网站首页>[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
边栏推荐
- Unity intelligent NPC production -- pre judgment walking (method 1)
- Use of snippets in vscode (code template)
- [trans]: spécification osgi
- Recherche de mots pour leetcode (solution rétrospective)
- Merge sort
- 支持多模多态 GBase 8c数据库持续创新重磅升级
- Page countdown
- Chinese notes of unit particle system particle effect
- C语言杂谈1
- Listview pull-down loading function
猜你喜欢

Recherche de mots pour leetcode (solution rétrospective)

django连接数据库报错,这是什么原因

远程升级怕截胡?详解FOTA安全升级

Magnifying glass effect

嵌入式数据库开发编程(零)

To the distance we have been looking for -- film review of "flying house journey"

Stm32cubemx (8): RTC and RTC wake-up interrupt

Heap sort summary
![[转]: OSGI规范 深入浅出](/img/54/d73a8d3e375dfe430c2eca39617b9c.png)
[转]: OSGI规范 深入浅出

Embedded database development programming (V) -- DQL
随机推荐
Unity synergy
xftp7与xshell7下载(官网)
[turn to] MySQL operation practice (III): table connection
2022/7/2 question summary
Lua determines whether the current time is the time of the day
十年不用一次的JVM调用
To the distance we have been looking for -- film review of "flying house journey"
Lua GBK and UTF8 turn to each other
Solon Logging 插件的添加器级别控制和日志器的级别控制
Unity find the coordinates of a point on the circle
Romance of programmers on Valentine's Day
UE 虚幻引擎,项目结构
This article is good
Lua wechat avatar URL
Unity get component
2022/7/1学习总结
【ES实战】ES上的native realm安全方式使用
Database under unity
2022/7/1 learning summary
64 horses, 8 tracks, how many times does it take to find the fastest 4 horses at least