Problem Link:
https://oj.leetcode.com/problems/recover-binary-search-tree/
We know that the inorder traversal of a binary search tree should be a sorted array. Therefore, we can compare each node w...
Problem Link:
https://oj.leetcode.com/problems/validate-binary-search-tree/
We inorder-traverse the tree, and for each node we check if current_node.val > prev_node.val. The code is as follows.
...
Problem Link:
https://oj.leetcode.com/problems/binary-tree-level-order-traversal/
Traverse the tree level by level using BFS method.
# Definition for a binary tree node
# class TreeNode:
# def...
Problem Link:
https://oj.leetcode.com/problems/symmetric-tree/
To solve the problem, we can traverse the tree level by level. For each level, we construct an array of values of the length 2^depth, ...
Problem Link:
https://oj.leetcode.com/problems/same-tree/
The following recursive version is accepted but the iterative one is not accepted...
# Definition for a binary tree node
# class TreeNode:...