FastPrepMaximum Sum with Equal-Index Switches
Problems/Maximum Sum with Equal-Index Switches

Maximum Sum with Equal-Index Switches

Intuit logoIntuit● MediumINTERNOA

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The source explicitly permits switches at equal values at the same index. Its illustrative total omits a shared value; this version counts every visited index once. Signed and empty-input rules are practice assumptions; about 90% match.

Two arrays a and b have equal length. Start in either array at index zero and visit every index from left to right, collecting the value at that index in the current array. At index i, you may switch arrays only if a[i] == b[i]. The common value is collected once. Return the maximum total after reaching the end.

The arrays need not be sorted. Equal values at different indices do not allow a switch. You must traverse the full length even when some values are negative. Empty arrays have total zero.

Function

maximumSwitchingSum(a: int[], b: int[]) → long

Examples

Example 1

a = [1,2,4,7,9,12,3,6]b = [1,5,7,8,9,3,5,7]return = 51

Choose b through the shared 9, then a through the end: 1+5+7+8+9+12+3+6=51.

Example 2

a = [1,10]b = [10,1]return = 11

No same-index equality exists, so a cross-index common value does not permit switching.

Constraints

  • For this exercise, assume equal lengths at most 200000 and values between -10^9 and 10^9. Return a signed 64-bit sum.

More Intuit Online Assessment questions

  • Employee Promotion OpportunitiesOA · Seen Oct 2026
  • Next Pascal Row CoefficientOA · Seen Oct 2026
  • Parse Router LogsOA · Seen Oct 2026
  • Longest Repeated Letter Block with Adjacent SwapsOA · Seen Oct 2026
  • Maximum Square-Free DivisorOA · Seen Oct 2026
  • Two Tribes from Taller-Person CountsOA · Seen Oct 2026
  • Shortest Path from an Encoded GraphOA · Seen Sep 2026
  • Oldest and Youngest EmployeesOA · Seen Sep 2026
  • Pressure-Isolation Shutdown OrderOA · Seen Sep 2026
  • Submask Sum QueriesOA · Seen Sep 2026

Similar questions at other companies

  • Maximum Game Score with Fixed Forward JumpsStripe · OAStripe interview questions
  • 0/1 KnapsackConfluent · OAConfluent interview questions
  • Minimum Cost to Tile a Strip with Widths 1, 2, and 3Infosys · OAInfosys interview questions
  • Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
  • Maximum Subarray SumStraive · OA
  • Longest Increasing Price SubsequenceOpenAI · OAOpenAI interview questions
  • Lowest-Cost Shirt Color ScheduleElevenLabs · OAElevenLabs interview questions
  • Maximum Game Board ScoreJP Morgan Chase · OAJP Morgan Chase interview questions
  • API Bandwidth AllocationArista Networks · OAArista Networks interview questions
  • Maximum Points by Deleting ElementsIBM · OAIBM interview questions

Interview reports that mention this question

  • Intuit OA: What It Tests (2026)

Intuit interview experiences

  • Intuit Software Engineering Intern - Full Stack OA Format
All Intuit interview questionsSee Intuit hiring insights
Saved
class Solution {
    public long maximumSwitchingSum(int[] a, int[] b) {
        // Write your code here
    }
}
Checking account…