ProdMatch
CompaniesCitiesRolesSign in

Companies

  • Google
  • Microsoft
  • Meta
  • Amazon
  • Apple
  • Atlassian
  • Nvidia
  • Oracle
  • See all 18 →

Cities

  • Bengaluru jobs
  • Hyderabad jobs
  • Pune jobs
  • Gurugram jobs
  • Noida jobs
  • Delhi NCR jobs
  • Mumbai jobs
  • Chennai jobs
  • Remote-India jobs

Roles

  • QA / SDET Engineers
  • Backend Engineers
  • Frontend Engineers
  • Full-stack Engineers
  • Data Analysts
  • Data Engineers
  • ML / AI Engineers
  • DevOps / SRE Engineers
  • All roles →

ProdMatch

  • About
  • Career guides
  • Compare
  • Salaries
  • Skills
  • DSA practice
  • Privacy
  • Terms
  • Sign in

© 2026 ProdMatch.ai · Built for India · DPDP Act 2023 compliant · Job data sourced from official company career pages.

Back to DSA
Sliding Windoweasy16 min

Best Time to Buy and Sell Stock

Sliding Window is a repeated product-company interview pattern because it tests whether you can turn a brute-force idea into a predictable invariant.

Open on LeetCode

Question

Given daily prices, find the maximum profit from one buy followed by one sell.

prices = [7, 1, 5, 3, 6, 4] -> 5

prices = [7, 6, 4, 3, 1] -> 0

Approach

Try framing your own approach first. The 30 seconds you think before peeking is where learning happens.

Clean Solution

Reveal the approach first.

How well did you understand?

Your rating tunes when this problem shows up again.

Common Mistakes

  • Do not allow selling before buying.
  • Return 0 when no profitable trade exists.

Next Similar Problems

Longest Substring Without Repeating CharactersmediumMinimum Window Substringhard