#include <iostream> #include <stack> #include <vector> #include <algorithm> #include <deque> using namespace std; #define error(format, ...) printf(format, __VA_ARGS__) struct TreeNode { TreeNode *left; TreeNode *right; int val; // TreeNode(int v) : val(v),left(NUL...