Algorithm · Squarepoint · Medium
Let prices be an integer array whose element prices[i] gives the value of one share on day i (0-indexed). Address the two variants below independently. One-transaction limit. You are allowed at most one buy-and-sell pair. Select a purchase day and a strictly later sale day. Short selling is forbidden. Report the largest possible profit, or return 0 when no trade can be profitable. Unlimited transactions. You may buy and sell as often as desired, provided each sale happens…
Checking your access…