A Game of long long || Upper Bound ||C++
Intuition\n Describe your first thoughts on how to solve this problem. \nIntuition is simple as we need to find upper bound for every digit in nums[i] if nums[i
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIntuition is simple as we need to find upper bound for every digit in nums[i] if nums[i] is twice greater than target than just return else find upper bound let\'s ay that is pos then find **pow(2,pos-i-1)** after this return ans+=pow. Need to focus on how we find power.\n\n# Complexity\n- Time complexity: O(n long(n))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n# Code\n```\nclass Solution {\npublic:\n\n    int numSubseq(vector<int>& nums, int target) {\n        sort(nums.begin(),nums.end());\n        int ans=0;const unsigned int M = 1000000007;\n        for(int i=0;i<nums.size();i++){\n            if(2*nums[i]>target)\n                return ans;\n            int temp=target-nums[i];\n            int pos=(upper_bound(nums.begin()+i,nums.end(),temp)-nums.begin());\n            int m=pos-i-1;\n            long long x=2,val=1;\n            while (m != 0) {\n                if (m & 1 != 0) {\n                    // x=(long long)(x) % M;\n                    val = (long long)(val* x) % M;\n                } \n                x = (long long)(x* x)%M ;\n                m /= 2; \n            }\n            ans=(int)(ans+val)%M;\n        }\n        return ans;\n    }\n};\n```
['Binary Search', 'C++']