FastPrepMaximum Payout with Context Switches
Problems/Maximum Payout with Context Switches

Maximum Payout with Context Switches

PhonePe logoPhonePe● HardFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a PhonePe online assessment. The report does not give the number limits or say exactly what happens to skipped task slots. Our version is about 94% the same as the reported question.

You are given two arrays, payoutA and payoutB, of equal length. Index i represents one task slot in a fixed sequence. In that slot, you may skip the slot, complete Startup A's task for payoutA[i], or complete Startup B's task for payoutB[i].

You may complete at most maxTasks tasks. Every completed task costs one day. If a completed task belongs to a different startup than the previous completed task, it also costs one idle context-switch day. Skipped slots consume no days and do not change the startup of the previous completed task.

The total number of task days plus context-switch days must not exceed days. Return the maximum total payout. Choosing no tasks is allowed and yields 0.

Function

maximumPayout(payoutA: int[], payoutB: int[], maxTasks: int, days: int) → long

Examples

Example 1

payoutA = [5,1,10]payoutB = [1,8,2]maxTasks = 2days = 2return = 15

Complete Startup A's tasks in slots 0 and 2. They cost two task days, require no context switch, and pay 5 + 10 = 15.

Example 2

payoutA = [5,1,10]payoutB = [1,8,2]maxTasks = 2days = 3return = 18

Complete Startup B's task in slot 1 and Startup A's task in slot 2. The two tasks and one switch consume three days, and the payout is 8 + 10 = 18.

Example 3

payoutA = [7,4]payoutB = [6,9]maxTasks = 0days = 4return = 0

No task may be completed when maxTasks is 0, so the maximum payout is 0.

Constraints

  • 1 <= payoutA.length = payoutB.length <= 100
  • 0 <= payoutA[i], payoutB[i] <= 10^9
  • 0 <= maxTasks <= payoutA.length
  • 0 <= days <= 2 * payoutA.length

More PhonePe interview questions

  • Constrained Jump SequencesOA · Seen Aug 2026
  • Substrings Without a Target SubsequenceOA · Seen Aug 2026
  • Luna and the Colorful SocksOA · Seen Jul 2026
  • Evaluate DivisionONSITE INTERVIEW · Seen Oct 2026
  • K-th Smallest Value in a Sorted MatrixONSITE INTERVIEW · Seen Oct 2026
  • Identify Two Failing Tests From an Oracle TranscriptONSITE INTERVIEW · Seen Sep 2026
  • Count Bowl SubarraysONSITE INTERVIEW · Seen Jul 2026
  • Reconstruct ItineraryONSITE INTERVIEW · Seen Jul 2026

Similar questions at other companies

  • Split Array to Minimize the Largest SumInfosys · OAInfosys interview questions
  • Largest Consistent Visiting GroupAuxoAI · OA
  • Delete K Subsets for Maximum ScoreRubrik · OARubrik interview questions
  • Optimize Discount Selection Under a Point BudgetPalantir · OAPalantir interview questions
  • Maximum Index-Weighted Sum with Disjoint SwapsVisa · OAVisa interview questions
  • Maximum Sum of HeightsVirtu Financial · OAVirtu Financial interview questions
  • Pressure-Isolation Shutdown OrderIntuit · OAIntuit interview questions
  • Get Minimum IncrementIBM · OAIBM interview questions
  • Jump Game with Prime-3 StepsUber · OAUber interview questions
  • Maximize Array Beauty After DeletionsPoint72 · OAPoint72 interview questions
All PhonePe interview questionsSee PhonePe hiring insights
Saved
class Solution {
    public long maximumPayout(int[] payoutA, int[] payoutB, int maxTasks, int days) {
      // write your code here
    }

}
Checking account…