Easy Binary Search Approach
\n\n# Complexity\n- Time complexity:\nO(n logm)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\n    public int[] successfulPairs(int[] spells, int[]
\n\n# Complexity\n- Time complexity:\nO(n logm)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\n    public int[] successfulPairs(int[] spells, int[] potions, long success) {\n        int n=spells.length;\n        int m=potions.length;\n        int[] arr= new int[n];\n        Arrays.sort(potions);\n        for(int i=0;i<n;i++){\n            long spell=spells[i];\n            long lo=0;\n            long hi=m-1;\n            long lb=-1;\n            while(hi>=lo){\n                long mid=lo+(hi-lo)/2;\n                long pair=spell*potions[(int)mid];\n                if(pair>=success){\n                    lb=mid;\n                    hi=mid-1;\n                }else lo=mid+1;\n            }if(lb!=-1) arr[i]+=m-lb;\n        }\n        return arr;\n    }\n}\n```
['Java']