FastPrepBest Score Switching Between Two Sorted Arrays
Problems/Best Score Switching Between Two Sorted Arrays

Best Score Switching Between Two Sorted Arrays

Adobe logoAdobe● HardFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: You find the best score of a path that may hop between two sorted lists at shared values. Two reports from Noida mention this classic task in the first round. A January 2022 post, made only of links, comes from a CS1 candidate. It pairs this task with a house-robber task. An April 2022 post comes from an MTS2 candidate with under two years of experience, who was rejected after the fifth round. It pairs this task with a longest-unique-substring task and some C++ questions. Neither post gives limits or examples.

The rules are those of the linked task, with one change. We return the score exactly as a 64-bit integer instead of modulo 10^9 + 7. We chose these limits: 1 to 5000 values per list, with values from 1 to 10^7. The exact 64-bit score is the answer. We wrote new examples.

Our version is about 90% the same as the reported questions.

You are given two strictly increasing integer arrays nums1 and nums2. A path starts at the first element of either array and walks through that array from left to right. Whenever the current value also appears in the other array, the path may move to that value in the other array and keep walking right from there. The path ends after the last element of the array it is in.

The score of a path is the sum of the values it walks through; a value found in both arrays is counted once, whether or not the path switches there. Return the largest possible score. It can be larger than a 32-bit integer can hold, so return it as a 64-bit integer.

Function

maxSwitchingScore(nums1: int[], nums2: int[]) → long

Examples

Example 1

nums1 = [3,6,10,14,20]nums2 = [1,6,8,9,14,15]return = 60

Before 6, the first list gives 3 and the second gives 1, so start on the first. Between 6 and 14, the first list has 10 and the second has 8 + 9 = 17, so switch at 6. After 14, 20 beats 15, so switch back at 14. The score is 3 + 6 + 17 + 14 + 20 = 60.

Example 2

nums1 = [5,11]nums2 = [2,4,7]return = 16

No value is in both lists, so no switch is possible. The first list sums to 16 and the second to 13, so the answer is 16.

Example 3

nums1 = [4,9,12]nums2 = [4,9,12]return = 25

Both lists are the same, so every path collects 4, 9 and 12 once each: 25.

Constraints

  • 1 <= nums1.length, nums2.length <= 5000
  • 1 <= nums1[i], nums2[i] <= 10^7
  • nums1 and nums2 are both strictly increasing.

More Adobe Phone Screen questions

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
  • Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
  • Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
  • Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
  • Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
  • Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
  • Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026

Similar questions at other companies

  • Split Array to Minimize the Largest SumNation with NaMo · PHONE SCREEN
  • Trapping Rain WaterOracle · PHONE SCREENOracle interview questions
  • Rain Kept Between WallsDocuSign · PHONE SCREENDocuSign interview questions
  • Jump GamePaytm · PHONE SCREENPaytm interview questions
  • Minimum Cost for a Target WeightPace Stock Broking Services · PHONE SCREEN
  • Container With Most WaterEPAM · PHONE SCREENEPAM interview questions
  • Container With Most WaterNuro · PHONE SCREENNuro interview questions
  • Jump Game IINavi · PHONE SCREEN
  • Best Stock Profit With a Sell FeeKaseya · PHONE SCREEN
  • Rebalance Bank Accounts to a Minimum BalanceRemitly · PHONE SCREENRemitly interview questions

Interview reports that mention this question

  • Adobe CS1 Interviews: 14 Experiences (Part 4 of 6)
  • Adobe MTS Interview Questions: 12 Experiences (Part 2 of 6)

Adobe interview experiences

  • Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
  • Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
  • Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
  • Adobe New Grad MTS Interview Questions: 7 Experiences
All Adobe interview questionsSee Adobe hiring insights
Saved
class Solution {
    public long maxSwitchingScore(int[] nums1, int[] nums2) {
        // Write your code here.
    }
}
Checking account…