FastPrepMaximum Profit with at Most K Transactions
Problems/Maximum Profit with at Most K Transactions

Maximum Profit with at Most K Transactions

Tekion logoTekion● HardFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Tekion phone screen. The report gives the trading rules and an example but not the number limits. Our version is about 97% the same as the reported question.

You are given the price of one batch of goods on consecutive days. You may complete at most k transactions. A transaction consists of buying once and selling later.

  • You must sell before buying again.
  • You may hold at most one batch at a time.
  • A completed buy-and-sell pair counts as one transaction.

Return the maximum profit possible.

Function

maxProfit(prices: int[], k: int) → int

Examples

Example 1

prices = [3,2,6,5,0,3]k = 2return = 7

Buy at 2 and sell at 6, then buy at 0 and sell at 3.

Constraints

  • 1 <= prices.length <= 1000
  • 0 <= k <= 100
  • 0 <= prices[i] <= 10^6

More Tekion interview questions

  • Peak Resource Usage Across Weighted IntervalsPHONE SCREEN · Seen Sep 2026
  • Dungeon GamePHONE SCREEN · Seen Sep 2026
  • IPOPHONE SCREEN · Seen Sep 2026
  • Coin Game From The EndsPHONE SCREEN · Seen Sep 2026
  • Open Lockers After Toggle PassesPHONE SCREEN · Seen Sep 2026
  • Maximum Concurrent Active LoansPHONE SCREEN · Seen Aug 2026
  • Largest Rectangle in HistogramONSITE INTERVIEW · Seen Sep 2026
  • Next Greater Element to the RightONSITE INTERVIEW · Seen Sep 2026
  • Koko Eating BananasONSITE INTERVIEW · Seen Sep 2026
  • Maximum Sum of a Unique-Element SubarrayONSITE INTERVIEW · Seen Jul 2026

Similar questions at other companies

  • Split Array to Minimize the Largest SumNation with NaMo · PHONE SCREEN
  • Trapping Rain WaterOracle · PHONE SCREENOracle interview questions
  • Minimum Length After Removing Arithmetic TriplesMedia.net · PHONE SCREEN
  • Select Transactions with Child-Pays-for-Parent PackagesCoinbase · PHONE SCREENCoinbase interview questions
  • Longest Consistent Activity StreakAtlassian · PHONE SCREENAtlassian interview questions
  • Longest Increasing Path in a MatrixNew Relic · PHONE SCREEN · ONSITE INTERVIEW
  • Longest Increasing Subsequence With Bounded Adjacent DifferenceGoogle · PHONE SCREENGoogle interview questions
  • Longest Increasing Subsequence With Bounded Adjacent DifferenceAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Count Ordered Combination Sums with Negative ValuesPinterest · PHONE SCREENPinterest interview questions
  • Minimum Matrix-Chain MultiplicationsGSA Capital · PHONE SCREEN
All Tekion interview questionsSee Tekion hiring insights
Saved
class Solution {
    public int maxProfit(int[] prices, int k) {
        // Write your solution here.
    }
}
Checking account…