I am not able to understand test case please elaborate how the output is coming 16 for this question.
Not able to understand test case
The given testcase is:
1
1 5 23 4 5 9 20
1 ->gives no. of test cases
1-> no. of transactions allowed 5-> prices of stocks in the sequence of days
23 4 5 9 20
So here we have the prices on stock from day 1 to day 5
To maximise the profit you buy the stock when its price is 4 and sell it when its price is 20
Since only 1 transaction was required here the above case fits best
giving us maximum profit as 20-4=16
I hope this was helpful
Thank You