/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/funcgoodNodes(root*TreeNode)int{maxVal:=math.MinInt32ans:=0vardfsfunc(root*TreeNode)dfs=func(root*TreeNode){ifroot==nil{return}raw:=maxValdeferfunc(){maxVal=raw}()ifroot.Val>=maxVal{ans++maxVal=root.Val}dfs(root.Left)dfs(root.Right)}dfs(root)returnans}