Best Time to Buy and Sell Stock — JavaScript easy interview problem
You are given an array `prices` where `prices[i]` is the price of a stock on day i. You want to maximize profit by choosing a single day to buy and a different day in the future to sell. Return the maximum profit. If no profit is possible, return 0.
Tags: kadane-adjacent, greedy
Practice this Arrays problem free in the JS Interview Playground with automated tests and unlockable solutions.