Java Solution for beginners. With simple explanation and some additional tips
Intuition\nBinary Search\n\n# Approach\nStep 1 : Sort potions \nStep 2 : get number of pair of successful potions and spells by using binary search. Try finding
# Intuition\nBinary Search\n\n# Approach\nStep 1 : Sort potions \nStep 2 : get number of pair of successful potions and spells by using binary search. Try finding smallest element in potions which can give you successful pair by subtracting index of samllest element by length of potions.\nStep 3 : store all the value in ans[] and return ans.\n\n\n# Tips\n1. In below code you can store ans[] values into spells[] which can help you reduce space complexity from O(n) to O(1). \n\n2. Instead of using function couSuc you can do binary search in for loop instead to save some more time. \n\n# Advantages\n1. This approach gives you consistent result and it is favorable for very large array. \n\n2. This code can be done in space complexity of O(1) instead of O(n). which makes it space efficient. \n\n# Disadvantages\n1. It is slower for small array. two Poiner method is favorable for smaler array\n\n# Complexity\n- Time complexity:\n O(n log n)\n\n- Space complexity:\nO(n)\n\n# Code\n```\nclass Solution {\n    public int[] successfulPairs(int[] spells, int[] potions, long success) {\n        Arrays.sort(potions);\n        int ans[] = new int[spells.length];\n        for(int i=0;i<spells.length;i++){\n            ans[i]=couSuc(spells[i],potions,success);\n        }\n        return ans;\n    }\n    private int couSuc(int a, int[] arr, long b){\n        int start=0,end=arr.length;\n        while(start<end){\n            int mid=start+(end-start)/2;\n            if((long)arr[mid]*a>=b){\n                end=mid;\n            }\n            else{\n                start=mid+1;\n            }\n        }\n        return arr.length-start;\n    }\n}\n```
['Array', 'Binary Search', 'Sorting', 'Java']