Skip to main content
Best Time to Buy and Sell Stock | AlgoCracked
AlgoCracked
ProblemsBest Time to Buy and Sell Stock
Easy54.0% acceptance
Blind75ArrayDynamic ProgrammingSliding Window

Best Time to Buy and Sell Stock

You are given an array prices where prices[i] is the price of a stock on day i . You may buy on one day and sell on a later day, at most once. Return the maximum profit you can achieve, or 0 if no profitable trade exists. Input format Input is a single array, e.g. [[7,1,5,3,6,4]] .

Loading workspace…