As reported: Adobe Computer Scientist 1 loop (Illustrator team, Bangalore, 2025), round 1 (DSA in pseudo code and C++): Best Time to Buy and Sell Stock with its variations II and III, House Robber I and II, and Single Number I and III.
This is LeetCode 121 — Best Time to Buy and Sell Stock.
prices[i] is a stock's price on day i. Choose one day to buy and a later day to sell. Return the largest profit possible, or 0 if no trade makes money.
Example 1
prices = [7,1,5,3,6,4]
Output: 5 (buy at 1, sell at 6)
Example 2
prices = [7,6,4,3,1]
Output: 0
Constraints: 1 ≤ prices.length ≤ 10^5; 0 ≤ prices[i] ≤ 10^4.
Code runner format: one JSON value per line: prices. Implement maxProfit(prices); the harness prints the profit.