class Solution { public: vector<int> V; void postTree(TreeNode* node) { if (node != NULL) { V.push_back(node->val); if (node->left != NULL) { postTree(node->left); } if (node->right != NULL) { postTree(node->right); } } } int findSecondMinimumValue(TreeNode* root) { postTree(root); int result = -1; if (V.size() < 2) { return -1; } sort(V.begin(), V.end()); for (auto v : V) { cout << v << " "; } cout << endl; for (int i = 1; i < V.size(); i++) { if (V[i - 1] == V[i]) { continue; } else { result = V[i]; break; } } return result; } };