#include <iostream>
#include <map>
using namespace std;
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
class Solution {
private:
int LEFT = 0;
int RIGHT = 1;
int res;
public:
int longestZigZag(TreeNode* root) {
if(!root) return 0;
res = 0;
dfs(root, LEFT, 0);
dfs(root, RIGHT, 0);
return res;
}
private:
void dfs(TreeNode* node, int d, int len){
if(!node) return;
res = max(res, len);
dfs(d == LEFT ? node->left : node->right, 1 - d, len + 1);
dfs(d == LEFT ? node->right : node->left, d, 1);
return;
}
};
int main() {
return 0;
}