摘要:
```C++ /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; ... 阅读全文
摘要:
```C++ /* // Definition for a Node. class Node { public: int val; vector children; Node() {} Node(int _val, vector _children) { val = _val; children = _children; ... 阅读全文
摘要:
```C++ /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; ... 阅读全文
摘要:
```python3 # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None from collections import d... 阅读全文
摘要:
```C++ /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: int ... 阅读全文
摘要:
两种思路,第一种就是在数组两边放置两个指针,第二种是在数组左边放置两个快慢指针。第二种方法更简洁,并且可以扩展至单链表的情形。推荐使用 C++ include include include include include include include include include using 阅读全文
摘要:
```C++ /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: int ... 阅读全文
摘要:
```python3
"""
# Definition for a Node.
class Node(object): def __init__(self, val, children): self.val = val self.children = children
"""
class Solution(object): def maxDepth(... 阅读全文
摘要:
```C++
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; ... 阅读全文
摘要:
```C++
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; ... 阅读全文