Can't find the error in this code (leetcode)

i was solving a question from leetcode, where you have to create a binary tree from given description array. I am stuck on this from a long time and still can’t find the error. can somebody help me please?

class Solution {
public:
    map<int,pair<TreeNode*,TreeNode*>> mp;
    map<int,bool> isChild;
    
    void solve(TreeNode* root)
    {
        if(!root)
            return;
        
        if(mp[root->val].first)
        {
            root->left=mp[root->val].first;
            solve(root->left);
        }
        else
            root->left=NULL;
        
        
        
        if(mp[root->val].second)
        {
            root->right=mp[root->val].second;
            solve(root->right);
        }
        else
            root->right=NULL;
        
        return;
    }
    
    
    
    
    TreeNode* createBinaryTree(vector<vector<int>>& descriptions) {
            for(int i=0;i<descriptions.size();i++)          
            {
                auto it=descriptions[i];
                isChild[it[1]]=true;
                TreeNode* node=new TreeNode(it[1]);
                if(it[2])
                    mp[it[0]].first=node;
                
                else
                    mp[it[0]].second=node;
            }
        
        
        
            TreeNode* root;
            for(auto it:isChild)
            {
                if(it.second==false)
                {
                    root=new TreeNode(it.first);
                    break;
                }
            }
        
        
            solve(root);
            return root;
            
        
    }
};

Problem Link : Loading...

Check the following simple solution.

Accepted

i am able to understand that my solution is not efficient and better solutions exist, but i am not able to see how my method is wrong.

Your code adds a pair <it[1],true> to the map<int,bool> isChild for each entry in the description vector. Then, your code searches this map for the pair<root,false>! How can this entry exist in the map if it has not been added before?

finally!!
i now i know what’s wrong and how i can i fix this.
thanks alot man (btw sorry for late reply, i was busy with my vivas and all)