FastPrepMaximum Profit With Value-Based Jumps
Problems/Maximum Profit With Value-Based Jumps

Maximum Profit With Value-Based Jumps

Google logoGoogle● MediumNEW GRADONSITE INTERVIEW

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The firsthand Google new-grad report gives a positive-integer array and allows taking a value to jump 1 + value positions or skipping to the next index. The underspecified negative-number follow-up is intentionally excluded.

You start at index 0 of an array of positive integers profits. At an index i, choose exactly one action:

  • Take profits[i] profit and jump to index i + 1 + profits[i].
  • Skip the profit and move to index i + 1.

The process ends after moving beyond the last index. Return the maximum total profit you can collect.

Function

maximumJumpProfit(profits: int[]) → long

Examples

Example 1

profits = [3,2,5,1,4]return = 7

Take 3 at index zero, jump to index four, and take 4.

Example 2

profits = [1,1,1,1]return = 2

Taking a one skips the next index, so at most two values can be collected.

Example 3

profits = [5,1,1]return = 5

Taking the first value jumps beyond the array and is optimal.

Constraints

  • 1 <= profits.length <= 200000.
  • 1 <= profits[i] <= 10^9.
  • The answer fits in a signed 64-bit integer.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Assign Escalations to TeamsAmazon · ONSITE INTERVIEW
  • Count Subsets With a Target SumSafe Security · ONSITE INTERVIEW
  • Maximum Subarray Sum with One DeletionOracle · ONSITE INTERVIEWOracle interview questions
  • Best Time to Buy and Sell Stock IIKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Coin ChangeMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Maximum SubarrayUpstart · ONSITE INTERVIEWUpstart interview questions
  • Smallest Sufficient TeamExpedia · ONSITE INTERVIEWExpedia interview questions
  • Maximum Product SubarrayHartford Financial Services · ONSITE INTERVIEWHartford Financial Services interview questions
  • Word BreakMoveworks · ONSITE INTERVIEWMoveworks interview questions
  • Maximum Value from Circular HousesDigitalOcean · ONSITE INTERVIEWDigitalOcean interview questions

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public long maximumJumpProfit(int[] profits) {
        // Write your code here.
    }
}
Checking account…