質問編集履歴
1
回答例の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -39,3 +39,21 @@
|
|
39
39
|
|
40
40
|
|
41
41
|
よろしくお願いします!
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
以下追記
|
46
|
+
|
47
|
+
調べていたら、このような回答を見つけたのですが、
|
48
|
+
|
49
|
+
まったくもってコードの仕組みがわからないです。
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
|
53
|
+
def max_depth(root)
|
54
|
+
|
55
|
+
root ? 1 + [max_depth(root.left), max_depth(root.right)].max : 0
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
```
|