Java. Binary Search. Spells and Potions
\n\nclass Solution {\n    public int search(int[] nums, long target, long sel) {\n        int start = 0;\n        int finish = nums.length - 1;\n        int med
\n```\nclass Solution {\n    public int search(int[] nums, long target, long sel) {\n        int start = 0;\n        int finish = nums.length - 1;\n        int med;\n        if (target < nums[start] * sel) return start;\n        if (target > nums[finish] * sel) return nums.length;\n\n        while (start < finish && nums[start] < nums[finish])\n        {\n            if (target == nums[start] * sel) return start;\n            med = (start + finish) / 2;\n            if (target > nums[med] * sel)\n                start = med + 1;\n            else\n                finish = med;\n\n        }\n        if (nums[start] * sel == target) return start;\n        if (nums[start] * sel < target)\n            return start + 1;\n        else\n            return start;\n    }\n\n    public int[] successfulPairs(int[] spells, int[] potions, long success) {\n        HashMap<Integer, Integer> dict = new HashMap<>();\n        Arrays.sort(potions);\n        int [] answ = new int[spells.length];\n        for (int i = 0; i < spells.length; i++) {\n            if (!dict.containsKey(spells[i]))\n                dict.put(spells[i], potions.length - search(potions, success, spells[i]));\n            answ[i] = dict.get(spells[i]);\n        }\n        return answ;\n    }\n}\n```
['Java']