FastPrepMaximum Task Reward Within a Time Budget
Problems/Maximum Task Reward Within a Time Budget

Maximum Task Reward Within a Time Budget

Google logoGoogle● MediumINTERNONSITE INTERVIEW

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Google intern virtual-onsite report describes choosing each task at most once under a finite time budget to maximize reward and specifically calls for descending-time 0/1 dynamic programming. The report omits numeric bounds and a signature, which are supplied for execution. Per the standing Google-source policy, the cover image is not displayed.

You are given parallel arrays timeCosts and rewards. Task i requires timeCosts[i] units of time and earns rewards[i] reward.

You may select each task at most once, and the total time of selected tasks must not exceed maxTime. Return the maximum total reward you can earn.

Function

maximumTaskReward(timeCosts: int[], rewards: int[], maxTime: int) → long

Examples

Example 1

timeCosts = [2,3,4]rewards = [4,5,7]maxTime = 5return = 9

Select the tasks with time costs 2 and 3 for total reward 4 + 5 = 9.

Example 2

timeCosts = [5,4,6]rewards = [10,7,12]maxTime = 4return = 7

Only the task with time cost 4 fits.

Example 3

timeCosts = [1,1,1]rewards = [2,3,4]maxTime = 2return = 7

Select the two highest-reward tasks. Each task may be used only once.

Constraints

  • 1 <= timeCosts.length = rewards.length <= 1000
  • 1 <= timeCosts[i] <= 10000
  • 0 <= rewards[i] <= 1000000000
  • 0 <= maxTime <= 10000
  • 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

Interview reports that mention this question

  • Google Intern Knapsack and Trees: 17 Experiences (Part 6 of 8)

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
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public long maximumTaskReward(int[] timeCosts, int[] rewards, int maxTime) {
        // Write your code here.
    }

}
Checking account…