Reported interview periodNot available
Maximum profit from repeated stock trades
You are given a price for each trading day and may complete as many round trips as you like, holding at most one share at a time. Report the largest total gain reachable across the whole window.
Practice focusRequirements - The input has two lines: a day count, then that many space-separated integer prices on the second line. The count matches the number of prices. - A round trip means buying one share on some day and selling it on a later day; positions cannot overlap and short selling is not allowed. - Return the total profit as a plain decimal string. A window with no profitable round trip, including a single day, yields 0 . - Prices are non-negative integers and the day count is at least one.…