full vector implementation with upperbound approach
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```\nclass Solution {\npublic:\n    \n    // int greater(vector<int>&arr,int val){\n    //     int n=arr.size();\n    //     int c=0;\n    //     for(int i=0;i<n;i++){\n    //         if(arr[i]>val){\n    //             c++;\n    //         }\n    //     }\n    //     return c;\n    // }\n    vector<int> resultArray(vector<int>& nums) {\n          int n=nums.size();\n        vector<int>arr1;\n         vector<int>arr2;\n\n         vector<int>sort1;\n         vector<int>sort2;\n        \n        int i=0;\n        int j=0;\n        int curr=2;\n        arr1.push_back(nums[0]);\n        arr2.push_back(nums[1]);\n        sort1.push_back(nums[0]);\n        sort2.push_back(nums[1]);\n     \n        while(curr<n){\n            \n          int c1=sort1.end()-upper_bound(sort1.begin(),sort1.end(),nums[curr]);\n           int c2=sort2.end()-upper_bound(sort2.begin(),sort2.end(),nums[curr]);\n            if(c1>c2 || (c1==c2 && sort1.size()<=sort2.size())){\n                sort1.insert(sort1.end()-c1,nums[curr]);\n                arr1.push_back(nums[curr++]);\n            }\n            else{\n                 sort2.insert(sort2.end()-c2,nums[curr]);\n                arr2.push_back(nums[curr++]);\n            }\n           \n        }\n        vector<int>ans;\n        for(auto x:arr1){\n           \n            ans.push_back(x);\n           \n        }\n         for(auto x:arr2){\n           \n            ans.push_back(x);\n             \n        }\n        return ans;\n    }\n};\n```
['Array', 'Binary Search', 'C++']