Best Time to Buy and Sell Stock

You are given an array prices where prices[i] is the price of a given stock on the ith day.

You may complete at most one transaction: choose one day to buy the stock and a different later day to sell. Your goal is to maximise the profit.

If no profitable transaction is possible, return 0.

Examples
Input: [7,1,5,3,6,4]
Output: 5
Hints
Related Problems

Best Time to Buy and Sell Stock

You are given an array `prices` where `prices[i]` is the price of a given stock on the *i*th day.