当前位置:网站首页>[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 synergy
- Time format conversion
- To the distance we have been looking for -- film review of "flying house journey"
- Unity connects to the database
- django连接数据库报错,这是什么原因
- TF-A中的工具介绍
- [turn to] MySQL operation practice (I): Keywords & functions
- Lua determines whether the current time is the time of the day
- 发现一个很好的 Solon 框架试手的教学视频(Solon,轻量级应用开发框架)
- LeetCode之單詞搜索(回溯法求解)
猜你喜欢
随机推荐
Ue4/ue5 illusory engine, material part (III), material optimization at different distances
Research on the value of background repeat of background tiling
Simple HelloWorld color change
Applet Live + e - commerce, si vous voulez être un nouveau e - commerce de détail, utilisez - le!
The next key of win generates the timestamp file of the current day
Listview pull-down loading function
Out and ref functions of unity
Unity ugui source code graphic
The present is a gift from heaven -- a film review of the journey of the soul
2022/7/1学习总结
[转]MySQL操作实战(三):表联结
Recherche de mots pour leetcode (solution rétrospective)
Learning notes of "hands on learning in depth"
Basic knowledge points of dictionary
UE fantasy engine, project structure
When will Wei Lai, who has been watched by public opinion, start to "build high-rise buildings" again?
UE 虚幻引擎,项目结构
Reverse one-way linked list of interview questions
Bucket sort
Listview is added and deleted at the index