Tap here to switch tabs
Problem
Submissions

Problem: Even Odd Tree

Even Odd Tree checks whether a binary tree has odd values in strictly increasing order on even levels and even values in strictly decreasing order on odd levels. Return true or false.

Statement

A binary tree is considered an Even Odd tree if it satisfies the following conditions:

The root of the binary tree is at level index 00, its child nodes are at level index 11, their children are at level index 22, and so on.

For every even indexed level, all nodes at that level have odd integer values in strictly increasing order from left to right.

For every odd indexed level, all nodes at that level have even integer values in strictly decreasing order from left to right.

Given the root of a binary tree, return true if the binary tree is an Even Odd tree, or false otherwise.

Constraints:

  • The number of nodes in the tree is in the range [1,105][1, 10^5].

  • 1≤1 \leq Node.val ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Even Odd Tree

Even Odd Tree checks whether a binary tree has odd values in strictly increasing order on even levels and even values in strictly decreasing order on odd levels. Return true or false.

Statement

A binary tree is considered an Even Odd tree if it satisfies the following conditions:

The root of the binary tree is at level index 00, its child nodes are at level index 11, their children are at level index 22, and so on.

For every even indexed level, all nodes at that level have odd integer values in strictly increasing order from left to right.

For every odd indexed level, all nodes at that level have even integer values in strictly decreasing order from left to right.

Given the root of a binary tree, return true if the binary tree is an Even Odd tree, or false otherwise.

Constraints:

  • The number of nodes in the tree is in the range [1,105][1, 10^5].

  • 1≤1 \leq Node.val ≤106\leq 10^6