Skip to content

Commit 8daf5df

Browse files
edit 547
1 parent 9ee3387 commit 8daf5df

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Your ideas/fixes/algorithms are more than welcome!
7474
|551|[Student Attendance Record I](https://leetcode.com/problems/student-attendance-record-i/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_551.java) | O(n)| O(1) | Easy| String
7575
|549|[Binary Tree Longest Consecutive Sequence II](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence-ii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_549.java) | O(n) |O(n) | Medium | Tree
7676
|548|[Split Array with Equal Sum](https://leetcode.com/problems/split-array-with-equal-sum/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_548.java) | O(n^2) |O(1) | Medium | Array
77-
|547|[Friend Circles](https://leetcode.com/problems/friend-circles/)|[Solution](../master/src/main/java/com/fishercoder/solutions/FriendCircles.java) | O(n^2) |O(n) | Medium | Union Find
77+
|547|[Friend Circles](https://leetcode.com/problems/friend-circles/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_547.java) | O(n^2) |O(n) | Medium | Union Find
7878
|546|[Remove Boxes](https://leetcode.com/problems/remove-boxes/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_546.java) | O(n^3) |O(n^3) | Hard| DFS, DP
7979
|545|[Boundary of Binary Tree](https://leetcode.com/problems/boundary-of-binary-tree/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_545.java) | O(n) |O(n) | Medium | Recursion
8080
|544|[Output Contest Matches](https://leetcode.com/problems/output-contest-matches/)|[Solution](../master/src/main/java/com/fishercoder/solutions/OutputContestMatches.java) | O(n) |O(n) | Medium | Recursion

src/main/java/com/fishercoder/solutions/FriendCircles.java renamed to src/main/java/com/fishercoder/solutions/_547.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
package com.fishercoder.solutions;
22

33
/**
4-
* There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. 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. And we defined a friend circle is a group of students who are direct or indirect friends.
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.
510
6-
Given a N*N matrix M representing the friend relationship between students in the class. If M[i][j] = 1, then the ith and jth students are direct friends with each other, otherwise not. And you have to output the total number of friend circles among all the students.
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.
714
815
Example 1:
916
Input:
@@ -28,7 +35,7 @@
2835
M[i][i] = 1 for all students.
2936
If M[i][j] = 1, then M[j][i] = 1.
3037
*/
31-
public class FriendCircles {
38+
public class _547 {
3239

3340
public int findCircleNum(int[][] M) {
3441
if (M == null || M.length == 0 || M[0].length == 0) return 0;

src/test/java/com/fishercoder/FriendCirclesTest.java renamed to src/test/java/com/fishercoder/_547Test.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.fishercoder;
22

3-
import com.fishercoder.solutions.FriendCircles;
3+
import com.fishercoder.solutions._547;
44
import org.junit.Before;
55
import org.junit.BeforeClass;
66
import org.junit.Test;
@@ -10,15 +10,15 @@
1010
/**
1111
* Created by fishercoder on 1/9/17.
1212
*/
13-
public class FriendCirclesTest {
14-
private static FriendCircles test;
13+
public class _547Test {
14+
private static _547 test;
1515
private static int expected;
1616
private static int actual;
1717
private static int[][] M;
1818

1919
@BeforeClass
2020
public static void setup() {
21-
test = new FriendCircles();
21+
test = new _547();
2222
}
2323

2424
@Before

0 commit comments

Comments
 (0)