Python Two Pointers Solution w/ sorting (WITHOUT binary search)
Intuition\n Describe your first thoughts on how to solve this problem. \nThe idea is to initially sort both the spells and potions array, and then initialize a 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe idea is to initially sort both the ```spells``` and ```potions``` array, and then initialize a variable called ```p``` at the last element of ```potions```. ```p``` will only move from right to left, while another pointer, ```s```, will iterate through ```spells``` from left to right. We will check if ``` spells[s]*potions[p] >= success ```. If so, keep on moving the ```p``` pointer to the left until that condition fails. Record the result once that condition fails for each iteration of ```spells```.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Since the order of our ```spells``` array is important in order to return the number of potions that will form a successful pair with each element in ```spell```, we will recreate the ```spells``` list as a nested list that stores each of its elements and its index.\n```Ex. spells = [5,1,3] -> spells = [[5,0],[1,1],[3,2]]```\n2. Sort both ```spells``` and ```potions```.\n3. Initialize ```result``` and ```p``` to ```[0]*len(spells)``` and ```len(potions)-1```, respectively. The ```result``` array will be returned in the end.\n4. Run a for-loop on ```spells``` and for each iteration, we run a while-loop that checks if ```spells[s][0]*potions[p] >= success```. If so, we decrement the ```p``` pointer until that condition fails. There\'s no point in checking further since we already found the potion with the least strength that will form a successful pair for the ```spell[s]``` spell.\n5. Once the while-loop breaks, we can compute the number of potions that will form a successful pair by doing ```len(potions)-p-1``` and replace the element\'s value in ```result``` on the ```spells[s][1]``` index.\n\n# Complexity\n- Time complexity: **O(nlog(n)+mlog(m)+n)** because we sorted both input lists and iterate through ```spells```\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: **O(n)**\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def successfulPairs(self, spells: List[int], potions: List[int], success: int) -> List[int]:\n        spells = [[spells[i],i] for i in range(len(spells))]\n        spells.sort()\n        potions.sort()\n\n        result = [0]*len(spells)\n        p = len(potions)-1\n        for s in range(len(spells)):\n            while p >= 0 and spells[s][0]*potions[p] >= success:\n                p -= 1\n            result[spells[s][1]] = len(potions)-p-1\n\n        return result\n```
['Array', 'Two Pointers', 'Sorting', 'Counting', 'Python3']