This commit is contained in:
2026-06-21 20:46:23 +10:00
parent c4cfce490e
commit f873a89c82
6 changed files with 227 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
package top100liked
import (
"testing"
)
// https://leetcode.cn/problems/symmetric-tree/description/?envType=study-plan-v2&envId=top-100-liked
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
func isSymmetric(root *TreeNode) bool {
return check(root.Left, root.Right)
}
func check(p, q *TreeNode) bool {
if p == nil && q == nil {
return true
}
if p == nil || q == nil {
return false
}
return p.Val == q.Val && check(p.Left, q.Right) && check(p.Right, q.Left)
}
func Test1(t *testing.T) {
}