-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #848 from 0xff-dev/559
Add solution and test-cases for problem 559
- Loading branch information
Showing
5 changed files
with
50 additions
and
23 deletions.
There are no files selected for viewing
29 changes: 15 additions & 14 deletions
29
leetcode/501-600/0559.Maximum-Depth-of-N-ary-Tree/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 14 additions & 2 deletions
16
leetcode/501-600/0559.Maximum-Depth-of-N-ary-Tree/Solution.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
package Solution | ||
|
||
func Solution(x bool) bool { | ||
return x | ||
type Node struct { | ||
Val int | ||
Children []*Node | ||
} | ||
|
||
func Solution(root *Node) int { | ||
if root == nil { | ||
return 0 | ||
} | ||
dep := 0 | ||
for _, c := range root.Children { | ||
dep = max(dep, Solution(c)) | ||
} | ||
return dep + 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.