Algorithm · Two Sigma · Easy
Problem Given a sequence of stock prices, solve the variant selected by the interviewer: Variant A: One transaction You may buy once and sell once at most, with the purchase occurring before the sale. Determine the greatest possible profit. Variant B: Multiple transactions You may make any number of transactions, but you may own no more than one share at a time. You must sell your current share before making another purchase. Determine the greatest possible profit. Input…
Checking your access…