FastPrepMaximum Income from Asset Trading
Problems/Maximum Income from Asset Trading

Maximum Income from Asset Trading

Jefferies logoJefferies● EasyFULLTIMEOA

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The Jefferies Codility report establishes that you begin with one asset, may hold at most one asset, have unlimited cash for purchases, and return the last nine digits of maximum income. The report does not label an employment category, so this record uses the repository full-time fallback. The source screenshots are not displayed because large overlays obscure the problem content.

You are given prices, where prices[i] is the price of one asset on day i. You begin before day 0 holding exactly one asset at no purchase cost.

On each day, you may perform at most one action:

  • If you hold an asset, you may sell it at that day's price.
  • If you do not hold an asset, you may buy one at that day's price. You always have enough cash to buy.
  • You may also do nothing.

You may hold at most one asset at any time. Income is total sale proceeds minus purchase costs. Return the maximum possible income modulo 1,000,000,000 (the last nine digits).

Function

maximumIncome(prices: int[]) → int

Examples

Example 1

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

Sell the initial asset for 4, buy for 1, and sell again for 3. The income is 4 - 1 + 3 = 6.

Example 2

prices = [1,5,3,8]return = 10

Sell at 5 after the first rise, then buy at 3 and sell at 8. Including the free initial asset, the maximum income is 10.

Example 3

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

Sell the initial asset on day 0; no later trade is profitable.

Constraints

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

More Jefferies Online Assessment questions

  • Repair a Binary SearchOA · Seen Oct 2026

Similar questions at other companies

  • Best Time to Buy and Sell StockFlexTrade · OAFlexTrade interview questions
  • Split Array to Minimize the Largest SumInfosys · OAInfosys interview questions
  • Split Array Largest SumAuxoAI · OA
  • Get Minimum IncrementIBM · OAIBM interview questions
  • Maximum Even-Sum Neighboring PairsDRW · OADRW interview questions
  • Minimize Total Input Cost (for LTMS)Salesforce · OASalesforce interview questions
  • Minimum Number of Taps to Water a GardenGoldman Sachs · OAGoldman Sachs interview questions
  • Maximize Protected City PopulationAmazon · OA
  • Find Minimum Cost to Shift MachinesCisco · OACisco interview questions
  • Network FormationPalantir · OAPalantir interview questions
See Jefferies hiring insights
Saved
class Solution {
    public int maximumIncome(int[] prices) {
        // Write your code here.
    }

}
Checking account…