← Questions

Best time to buy and sell stock

0
MetaGoogleAmazonCodingLast asked Nov 2026

A coding interview question asked in Amazon's coding round and at Google and Meta, last asked Nov 2026. It tests arrays, greedy and dynamic programming.

Given a list of daily prices for one asset, return the most profit you can make. First allow any number of buy-then-sell trades, holding at most one share at a time.

Sign in to unlock this question

The full prompt, the worked answer and your own canvas or code with the AI tutor. New accounts get 5 credits: each one unlocks a question for good.

Where it's asked

  • Amazon · Coding · Last asked Nov 202655 min · Usually two rounds; one is often an object-oriented design built in steps · No AI
  • Google · Recruiter screen · Last asked Nov 202630 min · Call with a recruiter
  • Meta · AI-enabled coding · Last asked Apr 202660 min · Several progressive tasks on a starter codebase in CoderPad with an AI assistant panel; usually two rounds · The first task usually without AI, later tasks with it

What it tests

arrays · greedy · dynamic programming

Your code and the AI tutor open when you unlock this question.