Example:
Given binary tree [3,9,20,null,null,15,7],
3
/ \
9 20
/ \
15 7
return its depth = 3.
int maxDepth(struct TreeNode* root){
if(!root)return 0;
return 1+fmax(maxDepth(root->left),maxDepth(root->right));
}
思路:由下往上加回去,如果該點空則回傳0否則回傳1+左右子樹之樹高較高者。
Leetcode 1. Two Sum (C/Python3)
Oct 25, 2023K-th Symbol in Grammar
Oct 25, 2023You are given a 0-indexed sorted array of integers nums.
Sep 16, 2023Rectangle ( MAC split screen / resize window shortcut ) ( MAC 分屏 / 調整視窗大小 快捷鍵 ) windows 上 win + 左右調整視窗分屏在MAC沒有預設鍵位 開源免費軟體 Rectangle 能做到這件事情 官網直接下載安裝 https://rectangleapp.com
Dec 13, 2022or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up