Tell inputs for which wrong
hello @sgdon142
test ur code for this->
3
2
6
10 22 5 75 65 80
3
4
20 580 420 900
1
5
100 90 80 50 25
output
87
1040
0
but in case 2
ur pairs are(20,900) and (580,420) but how can u but how can u buy on the day 3 and sell on day 2. and if we can do this then i have better pairs for test 1 (5,80) ,(10,75) i.e 140 . pliz describe in details . and also correct me if i am wrong.
for case 2.
buy 20 then sell at 580 > profit …560
and then again buy at 420 and sell at 900 > profit …480
net profit-> 560 + 480 => 1040
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.