Skip to content

Commit 8f0c764

Browse files
refactor 547
1 parent 4ed5720 commit 8f0c764

File tree

1 file changed

+0
-35
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+0
-35
lines changed

src/main/java/com/fishercoder/solutions/_547.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,5 @@
11
package com.fishercoder.solutions;
22

3-
/**
4-
*547. Friend Circles
5-
*
6-
*There are N students in a class.
7-
* Some of them are friends, while some are not. Their friendship is transitive in nature.
8-
* For example, if A is a direct friend of B, and B is a direct friend of C, then A is an indirect friend of C.
9-
* And we defined a friend circle is a group of students who are direct or indirect friends.
10-
11-
Given a N*N matrix m representing the friend relationship between students in the class.
12-
If m[i][j] = 1, then the ith and jth students are direct friends with each other, otherwise not.
13-
And you have to output the total number of friend circles among all the students.
14-
15-
Example 1:
16-
Input:
17-
[[1,1,0],
18-
[1,1,0],
19-
[0,0,1]]
20-
Output: 2
21-
Explanation:The 0th and 1st students are direct friends, so they are in a friend circle.
22-
The 2nd student himself is in a friend circle. So return 2.
23-
24-
Example 2:
25-
Input:
26-
[[1,1,0],
27-
[1,1,1],
28-
[0,1,1]]
29-
Output: 1
30-
Explanation:The 0th and 1st students are direct friends, the 1st and 2nd students are direct friends,
31-
so the 0th and 2nd students are indirect friends. All of them are in the same friend circle, so return 1.
32-
33-
Note:
34-
N is in range [1,200].
35-
m[i][i] = 1 for all students.
36-
If m[i][j] = 1, then m[j][i] = 1.
37-
*/
383
public class _547 {
394

405
public static class Solution1 {

0 commit comments

Comments
 (0)