[Help] Why Binary Search gives TLE ?
I have code it using binary search.\n\ncomplexity can be O(nlog(1e9)).\nstill it gives TLE. while other users having same approach got it accepted.\nPlease help
I have code it using binary search.\n\ncomplexity can be O(nlog(1e9)).\nstill it gives TLE. while other users having same approach got it accepted.\nPlease help where i am missing something?\nThanks in advance.\n```\nclass Solution {\npublic:\n    int minimumEffort(vector<vector<int>>& a) {\n        sort(a.begin(),a.end(),[&](vector<int> p,vector<int> q){\n            if(p[1]-p[0] > q[1]-q[0])\n                return true;\n            return false;\n        });\n        int n = a.size();\n        auto okk = [&](int m){\n            for(int i = 0;i<n;i++)\n            {\n                if(m < a[i][1])\n                    return false;\n                m -= a[i][0];\n            }\n            return true;\n        };\n        int l = 1,r = 1e9;\n        int s = 0;\n        for(auto v:a)\n        {\n            l = max(l,v[1]);\n            s+=v[0];\n        }\n        l = max(s,l);\n        int ans;\n        while(l < r)\n        {\n            int m = (l+r)/2;\n            if(okk(m))\n            {\n                r = m;\n                ans = m;\n            }\n            else\n            {\n                l = m+1;\n            }\n            // cout<<l<<" "<<r<<" "<<m<<endl;\n        }\n        return ans;\n    }\n};\n```
['Binary Tree']