Skip to content

Commit 456a7b8

Browse files
format
1 parent 31b4103 commit 456a7b8

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Your ideas/fixes/algorithms are more than welcome!
110110
|515|[Find Largest Value in Each Tree Row](https://leetcode.com/problems/find-largest-value-in-each-tree-row/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_515.java) | O(n) |O(k) | Medium| BFS
111111
|514|[Freedom Trail](https://leetcode.com/problems/freedom-trail/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_514.java) | O(?) |O(?) | Hard | DP
112112
|513|[Find Bottom Left Tree Value](https://leetcode.com/problems/find-bottom-left-tree-value/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_513.java) | O(n) |O(k) | Medium| BFS
113-
|508|[Most Frequent Subtree Sum](https://leetcode.com/problems/most-frequent-subtree-sum/)|[Solution](../master/src/main/java/com/fishercoder/solutions/MostFrequentSubtreeSum.java) | O(n) |O(n) | Medium| DFS, Tree
113+
|508|[Most Frequent Subtree Sum](https://leetcode.com/problems/most-frequent-subtree-sum/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_508.java) | O(n) |O(n) | Medium| DFS, Tree
114114
|507|[Perfect Number](https://leetcode.com/problems/perfect-number/)|[Solution](../master/src/main/java/com/fishercoder/solutions/PerfectNumber.java) | O(sqrt(n)) |O(1) | Easy| Math
115115
|506|[Relative Ranks](https://leetcode.com/problems/relative-ranks/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_506.java) | O(nlogn) |O(n) | Easy|
116116
|505|[The Maze II](https://leetcode.com/problems/the-maze-ii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_505.java) | O(m*n) |O(m*n) | Medium| BFS

src/main/java/com/fishercoder/solutions/MostFrequentSubtreeSum.java renamed to src/main/java/com/fishercoder/solutions/_508.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import java.util.*;
66

77
/**
8-
* Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a node is defined as the sum of all the node values formed by the subtree rooted at that node (including the node itself). So what is the most frequent subtree sum value? If there is a tie, return all the values with the highest frequency in any order.
8+
* Given the root of a tree, you are asked to find the most frequent subtree sum.
9+
* The subtree sum of a node is defined as the sum of all the node values formed by the subtree rooted at that node (including the node itself).
10+
* So what is the most frequent subtree sum value? If there is a tie, return all the values with the highest frequency in any order.
911
1012
Examples 1
1113
Input:
@@ -24,7 +26,7 @@
2426
2527
Note: You may assume the sum of values in any subtree is in the range of 32-bit signed integer.
2628
*/
27-
public class MostFrequentSubtreeSum {
29+
public class _508 {
2830

2931
//my purely original but verbose solution
3032
public int[] findFrequentTreeSum(TreeNode root) {

src/test/java/com/fishercoder/MostFrequentSubtreeSumTest.java renamed to src/test/java/com/fishercoder/_508Test.java

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

33
import com.fishercoder.common.classes.TreeNode;
4-
import com.fishercoder.solutions.MostFrequentSubtreeSum;
4+
import com.fishercoder.solutions._508;
55
import org.junit.Before;
66
import org.junit.BeforeClass;
77
import org.junit.Test;
88

99
import static org.junit.Assert.assertArrayEquals;
1010

11-
public class MostFrequentSubtreeSumTest {
12-
private static MostFrequentSubtreeSum test;
11+
public class _508Test {
12+
private static _508 test;
1313
private static int[] expected;
1414
private static int[] actual;
1515
private static TreeNode root;
1616

1717
@BeforeClass
1818
public static void setup(){
19-
test = new MostFrequentSubtreeSum();
19+
test = new _508();
2020
}
2121

2222
@Before

0 commit comments

Comments
 (0)