0 out of 464 challenges solved
Write a Python function `max_product_pair(arr)` that takes a list of integers `arr` and returns a tuple containing the pair of integers from the list that have the highest product. If the list contains fewer than two elements, return `None`. #### Example Usage ```python [main.nopy] print(max_product_pair([1, 2, 3, 4, 7, 0, 8, 4])) # Output: (7, 8) print(max_product_pair([0, -1, -2, -4, 5, 0, -6])) # Output: (-4, -6) print(max_product_pair([1, 2, 3])) # Output: (2, 3) print(max_product_pair([5])) # Output: None ``` #### Constraints - The input list can contain both positive and negative integers. - The function should handle edge cases, such as lists with fewer than two elements.
def max_product_pair(arr): """ Find the pair of integers in the list that have the highest product. Args: arr (list): A list of integers. Returns: tuple: A tuple containing the pair of integers with the highest product, or None if not possible. """ # Check if the list has fewer than two elements if len(arr) < 2: return None # Placeholder for the solution pass