Grokking 75: Top Coding Interview Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Solution: Even Odd Tree
On this page

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:

  1. At every even-indexed level (starting from 0), all node values must be odd and arranged in strictly increasing order from left to right.
  2. At every odd-indexed level, all node values must be even and arranged in strictly decreasing order from left to right.

Examples

Example 1

  • Input:
    1
   / \
  10  4
 / \
3   7
  • Expected Output: true

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page