当前位置:网站首页>[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
- Programmers' experience of delivering takeout
- [leetcode] integer inversion [7]
- Simple modal box
- Stm32cubemx (8): RTC and RTC wake-up interrupt
- Common technologies of unity
- PMP考试敏捷占比有多少?解疑
- 质量体系建设之路的分分合合
- A complete attack chain
- [allocation problem] 455 Distribute cookies
猜你喜欢
C语言杂谈1
GBase数据库助力湾区数字金融发展
[interval problem] 435 Non overlapping interval
Collapse of adjacent vertical outer margins
【论文笔记】Multi-Goal Reinforcement Learning: Challenging Robotics Environments and Request for Research
支持多模多态 GBase 8c数据库持续创新重磅升级
服务熔断 Hystrix
对象的序列化
Stm32cubemx (8): RTC and RTC wake-up interrupt
Research on the value of background repeat of background tiling
随机推荐
stm32Cubemx(8):RTC和RTC唤醒中断
Romance of programmers on Valentine's Day
Simple modal box
Unity check whether the two objects have obstacles by ray
3dsmax scanning function point connection drawing connection line
[turn]: Apache Felix framework configuration properties
Basic knowledge points of dictionary
3dsmax snaps to frozen objects
Pause and resume of cocos2dx Lua scenario
Count sort
cocos_ Lua loads the file generated by bmfont fnt
Magnifying glass effect
Download and use of font icons
[sum of two numbers] 169 sum of two numbers II - enter an ordered array
Generate filled text and pictures
Database under unity
[turn to] MySQL operation practice (I): Keywords & functions
[interval problem] 435 Non overlapping interval
Common technologies of unity
GameObject class and transform class of unity