Successful Pairs of spells and Potions
Easy approach Binary search --\nPlease Upvote\n\n\nclass Solution {\npublic:\n    vector<int> successfulPairs(vector<int>& s, vector<int>& p, long long ss) {\n 
**Easy approach Binary search --**\n**Please Upvote**\n\n```\nclass Solution {\npublic:\n    vector<int> successfulPairs(vector<int>& s, vector<int>& p, long long ss) {\n           sort(p.begin() , p.end());\n          vector<long long> res(s.size());\n          for(int i = 0 ; i< s.size() ; ++i){\n              res[i] = (ss/s[i]);\n          }\n        \n        vector<int> ans;\n        for(int i = 0 ;  i < s.size() ; ++i){\n            \n            if(ss <= 1LL*res[i]*s[i] ){\n                 int ind = lower_bound(p.begin() , p.end() , res[i])  - p.begin() ;   \n                ans.push_back(p.size() - ind);\n            }else{\n                 int ind = upper_bound(p.begin() , p.end() , res[i])  - p.begin() ;\n                      \n                ans.push_back(p.size() - ind);\n            }                   \n           \n        }\n           \n        return ans;\n        \n    }\n};\n\n```
['Binary Tree']