Binary Search for Success.
Intuition\n Describe your first thoughts on how to solve this problem. \nUsing Binary Search for suucess.\n\n# Approach\n Describe your approach to solving the 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUsing Binary Search for suucess.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- Sort the array.\n- Binary Search to locate the dividing element.\n- Dividing element is where the product is just started to get greater.\n  For Ex.\n  spell = 5,\n  potions = [1,2,3,4,5]\n  success = 16\n  then, dividing element = 4 (index = 3);\n- subtracting the index with the length.\n\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(N*log(M) + MlogM)\n*MlogM for Sorting.\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n\n![leetcodeupvotetrick.png](https://assets.leetcode.com/users/images/8b7ef33d-9a39-409f-916e-353e6dd88607_1680463496.6290069.png)\n\n\n# Code\n```\nclass Solution {\n    public int[] successfulPairs(int[] arr, int[] arr1, long suc) {\n        int[] res = new int[arr.length];\n        Arrays.sort(arr1);\n        int l, r, mid;\n        long t;\n        for (int i = 0; i < arr.length; i++) {\n            l = 0;\n            r = arr1.length - 1;\n            while (l <= r) {\n                mid = (l + r) / 2;\n                t = arr[i];\n                if (arr1[mid] * t >= suc) {\n                    r = mid - 1;\n                    if(r==-1){\n                        res[i] = arr1.length;\n                    }\n                } else if (arr1[mid] * t < suc) {\n                    if (mid + 1 < arr1.length && arr1[mid + 1] * t >= suc) {\n                        res[i] = arr1.length - (mid + 1);\n                        break;\n                    }\n                    l = mid + 1;\n                }\n            }\n        }\n\n        return res;\n    }\n}\n\n```
['Java']