Develop a functionality to find the maximum profit from buying and selling a product, calculated from the product price dataset.
Write a Python function `max_profit` that calculates and returns the maximum profit that can be obtained from a given list of product prices. The profit is determined by finding a day to buy the product at the lowest possible price and a different day to sell the product at the highest possible price. ### Parameters - `prices` (list of int): A list of integers where each integer signifies the product's price for a particular day. ### Returns - int: The maximum possible profit, which is calculated as the difference between the lowest and the highest prices from the input list. ### Examples ```python # The highest price is 5 and the lowest price is 1, hence, the maximum profit is 5 - 1 = 4 max_profit([1,2,3,4,5]) # Returns: 4 # The highest price is 12 and the lowest price is 1, hence, the maximum profit is 12 - 1 = 11 max_profit([1,2,4,6,12]) # Returns: 11 # The highest price is 9 and the lowest price is 3, hence, the maximum profit is 9 - 3 = 6 max_profit([3,6,9]) # Returns: 6 ``` ## Template Code ```python def max_profit(prices): pass # Test cases print(max_profit([1,2,3,4,5])) # Returns: 4 print(max_profit([1,2,4,6,12])) # Returns: 11 print(max_profit([3,6,9])) # Returns: 6 ```