Hi, in this programming assignment I am required to find out the maximum profit (positive or negative) that can be earned during the week, given by a buyer. A person can buy share on any day and sell on any day, provided that day of selling > day of buying. Up to the point my code looks like this:
The question I have is how to make sure that a buyer buys a share firsthand and sells it only after having obtained it, for the array 'prices[]': 67000, 73000, 57000, 63000, 47000. In other words how to make sure that the share firstly is bought and sold only after obtained? Thank you.
P.S.I know that it has to do with O(n^2), but I have no idea what that means. Thank you very much for the help!