C++ Binary Search (mlogm)
\nclass Solution {\npublic:\n    int earliestSecondToMarkIndices(vector<int>& v, vector<int>& ci) {\n        int n = v.size();\n        int m = ci.size();\n    
```\nclass Solution {\npublic:\n    int earliestSecondToMarkIndices(vector<int>& v, vector<int>& ci) {\n        int n = v.size();\n        int m = ci.size();\n        \n        int l=0,h=m+1;\n        while(l<h){\n            int mid = l+(h-l)/2;\n            //cout<<mid<<" "; \n            if(solve(v,ci,mid)){\n                h = mid;\n            }else{\n                l = mid+1;\n            }\n        }\n        return h == m+1 ? -1 : h;\n    }\n    bool solve(vector<int>&v ,vector<int>&ci ,int mid){\n        map<int,int>lo;\n        for(int i=0;i<mid;i++){\n            lo[ci[i]]=i;\n        }\n        if(lo.size() != v.size()) return false;\n        int cnt=0;\n        for(int i=0;i<mid;i++){\n            \n            if(i == lo[ci[i]]){\n                //cout<<cnt<<" ----> "<<mid<<endl;\n                \n                if(cnt < v[ci[i]-1] )\n                    return false;\n                else\n                    cnt-= v[ci[i]-1];\n            }else\n                cnt++;\n        }\n       \n        return true;\n    }\n};\n\n```
['C', 'Binary Tree']