Grind 75 · Day 4 · Free cheat sheet

Best Time to Buy and Sell Stock

The whole problem on 2 pages: the one-pass solution, a visual walkthrough, edge cases and the follow-up questions interviewers ask.

Download the PDF

2 pages · A4 · 0.8 MB · free

Page 1 of the cheat sheet: a price chart showing buy at 1 and sell at 6 for a profit of 5
Download the PDF

2 pages · A4 · 0.8 MB · free

Download not starting? Open it in your browser.

What’s inside

  • The key insight, drawn on a price chart
  • The solution in Python, Java and JavaScript
  • A step-by-step dry run
  • 4 edge cases, including the max − min trap
  • What to say in the interview, in 5 steps
  • Follow-ups: the rest of the stock problem family
← All Grind 75 cheat sheets