Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit456a7b8

Browse files
format
1 parent31b4103 commit456a7b8

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.javarenamed 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
importjava.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-
publicclassMostFrequentSubtreeSum {
29+
publicclass_508 {
2830

2931
//my purely original but verbose solution
3032
publicint[]findFrequentTreeSum(TreeNoderoot) {

‎src/test/java/com/fishercoder/MostFrequentSubtreeSumTest.javarenamed 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
packagecom.fishercoder;
22

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

99
importstaticorg.junit.Assert.assertArrayEquals;
1010

11-
publicclassMostFrequentSubtreeSumTest {
12-
privatestaticMostFrequentSubtreeSumtest;
11+
publicclass_508Test {
12+
privatestatic_508test;
1313
privatestaticint[]expected;
1414
privatestaticint[]actual;
1515
privatestaticTreeNoderoot;
1616

1717
@BeforeClass
1818
publicstaticvoidsetup(){
19-
test =newMostFrequentSubtreeSum();
19+
test =new_508();
2020
}
2121

2222
@Before

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp