Here is my O(n) solution. Is it neat?
class Solution {\n    public:\n        TreeNode *buildTree(vector<int> &inorder, vector<int> &postorder) {\n            if(inorder.size() == 0)return NULL;\n   
    class Solution {\n    public:\n        TreeNode *buildTree(vector<int> &inorder, vector<int> &postorder) {\n            if(inorder.size() == 0)return NULL;\n            TreeNode* p;\n            TreeNode* root;\n            vector<int> vint;\n            vector<TreeNode*> vtn;\n            root = new TreeNode(postorder.back());\n            vtn.push_back(root);\n            postorder.pop_back();\n            while(true)\n            {\n                if(inorder.back() == vtn.back()->val)\n                {\n                    p = vtn.back();\n                    vtn.pop_back();\n                    inorder.pop_back();\n                    if(inorder.size() == 0) break;\n    \t\t\t\tif(vtn.size())\n    \t\t\t\t\tif(inorder.back() == vtn.back()->val)continue;\n                    p->left = new TreeNode(postorder.back());\n    \t\t\t\tpostorder.pop_back();\n                    vtn.push_back(p->left);\n                }\n                else\n                {\n                    p = new TreeNode(postorder.back());\n                    postorder.pop_back();\n                    vtn.back()->right = p;\n                    vtn.push_back(p);\n                }\n            }\n    \t\treturn root;\n        }\n    };
[]