Back to problems

Max Adjacent Stock Price Change

Algorithm · Instacart · Easy

Problem Given a list of stock record objects, where each record contains a date and a price, sort the records by date in ascending order. Compare adjacent records and compute the price change from the earlier date to the later date. Return the largest signed adjacent change together with the two dates that produced it, in the form [change, start_date, end_date]. A decline is negative, so the maximum is the greatest signed change rather than the largest absolute movement.…

Checking your access…