Back to course home
0% completed
Solution: Even Odd Tree
Problem Statement
Given a binary tree, return true
if it is an Even-Odd
tree. Otherwise, return false
.
The Even-odd
tree must follow below two rules:
- At every
even-indexed
level (starting from 0), all node values must beodd
and arranged instrictly increasing
order fromleft
toright
. - At every
odd-indexed
level, all node values must beeven
and arranged instrictly decreasing
order fromleft
toright
.
Examples
Example 1
- Input:
1
/ \
10 4
/ \
3 7
- Expected Output:
true
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible