just barely passed but used simple small to large merge technique
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nconst int N = 1e5;\nclass Solution {\npublic:\n    map<int,bool> smaintestval(vector<vector<int>>&g , vector<int>&nums , vector<int>&sol , int st, int p){\n        map<int,bool >m;\n        m[nums[st]] = 1 ;\n        int mini = nums[st];\n        bool f= false;\n        for(auto x : g[st]){\n            map<int,bool>hi = smaintestval(g, nums, sol , x, st);\n            if(m.size() < hi.size()){\n                m.swap(hi);\n            }\n            for(auto he : hi){\n                m[he.first] = 1;\n            }\n            mini = min(sol[x], mini);\n        }\n        if(m.find(1) == m.end()){\n            sol[st]= 1 ;\n        }\n        else {\n          \n            for(int i = mini; i<= N +1 ; i++ ){\n                if(m.find(i) == m.end()){\n                    sol[st] = i;\n                    break;\n                }\n            }\n        }\n\n        return m;\n    }\n    vector<int> smallestMissingValueSubtree(vector<int>& parents, vector<int>& nums) {\n        int n = nums.size();\n        vector<vector<int>>g(n);\n        for(int i = 1  ; i<n ;i++){\n             g[parents[i]].push_back(i);\n        }\n        vector<int>sol( n  );\n        for(int i = 0 ; i<nums.size() ; i++){\n            sol[i] = nums[i];\n        }\n        map<int, int >m;\n        smaintestval(g, nums, sol , 0 , -1);\n        return sol;\n    }\n};\n```
['C++']