In this LeetCode-style problem, you need to implement a function that finds the maximum profit from buying and selling a stock once. Identify the line with a logical error in the order of operations and select the correct implementation to fix it. Pay attention to how the minimum price and maximum profit are updated in each iteration.