FastPrepBest Time to Buy and Sell Stock II
Problems/Best Time to Buy and Sell Stock II

Best Time to Buy and Sell Stock II

Point72 logoPoint72● EasyINTERNNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Point72 interview report names this task: get the most stock profit with unlimited transactions while holding at most one share. The report does not give a full portable contract. So this version uses these fixed rules: prices are finite nonnegative integers, a sell and then a buy on the same day is allowed without changing the profit, and you return the maximum profit as an integer.

Given daily prices, return the maximum profit obtainable by any number of buy-then-sell transactions while holding at most one share at a time.

Function

maxProfit(prices: int[]) → int

Examples

Example 1

prices = [7,1,5,3,6,4]return = 7

Take the rises from one to five and from three to six.

Example 2

prices = [1,2,3,4,5]return = 4

The entire increasing run yields four.

Constraints

  • 0 <= prices.length <= 100000
  • 0 <= prices[i] <= 100000

More Point72 interview questions

  • Find Minimum in a Rotated Sorted ArrayPHONE SCREEN · Seen Aug 2026
  • Generate an Optimal Portfolio Trading ReportPHONE SCREEN · Seen Apr 2026
  • Maximize Array Beauty After DeletionsOA · Seen Aug 2026
  • Simulate a Deterministic Finite AutomatonOA · Seen Aug 2026
  • Initial Public OfferingOA · Seen Jul 2026
  • Test the HypothesisOA · Seen Jul 2026
  • Get Triplet CountOA · Seen Jul 2026
  • Internet Service Provider Monthly ReportOA · Seen Jul 2026
  • Server SelectionOA · Seen Jul 2026
  • Lexicographically Smallest String After Substring OperationOA · Seen May 2026

Similar questions at other companies

  • Best Stock Trade with Buy and Sell DaysGoogle · PHONE SCREENGoogle interview questions
  • Can Place FlowersAgoda · PHONE SCREENAgoda interview questions
  • Maximum Later Checkpoint Altitude GainYellow.ai · PHONE SCREEN
  • Assign CookiesAmazon · PHONE SCREEN
  • Maximum Profit with Exactly One Stock TransactionRetool · PHONE SCREEN · ONSITE INTERVIEWRetool interview questions
  • Best Time to Buy and Sell StockOracle · PHONE SCREEN · ONSITE INTERVIEWOracle interview questions
  • Best Time to Buy and Sell StockJP Morgan Chase · PHONE SCREENJP Morgan Chase interview questions
  • Choose the Front Football TeamAnduril · PHONE SCREENAnduril interview questions
  • Best Time to Buy and Sell StockBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Best Time to Buy and Sell StockHeadlands Technologies · PHONE SCREEN · ONSITE INTERVIEWHeadlands Technologies interview questions
All Point72 interview questionsSee Point72 hiring insights
Saved
class Solution {
    public int maxProfit(int[] prices) {
      // Write your code here.
    }

}
Checking account…