# Binary Tree Count good node ## 原文 https://leetcode.com/problems/count-good-nodes-in-binary-tree/description/ ## 題意 計算好節點總數。 ## What is good node ? 從任意節點到這一個節點,假設任意節點都比節點小或是相等,即為好節點。 ## 變數說明 任意節點中抓最大的 `maxValue` ; 這一個節點 `node.value` ; ```python3=1 res = 1 if maxValue <= node.value else 0 ``` aka (also known as) ```python3=1 res = 1 if node.value >= maxValue else 0 ``` ## playground https://leetcode.com/problems/count-good-nodes-in-binary-tree/submissions/ ## ref https://youtu.be/7cp5imvDzl4?si=goh--WJ5Puax89TT
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up