FastPrepPair Up an Array So Every Pair Sum Divides by k
Problems/Pair Up an Array So Every Pair Sum Divides by k

Pair Up an Array So Every Pair Sum Divides by k

Adobe logoAdobe● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: You decide whether an array can be split into pairs whose sums are all multiples of k. The source is one report by a fresher who tried for an Adobe MTS 1 role and was rejected. It had three coding problems in its first round. That round was a 60-minute video interview in March 2022, held by an engineer with four years of experience. This is the first problem. The report names the problem only by a title and shows a short summary that is cut off part-way. The author adds no wording, limits, examples or approach.

We take the task from that summary. It gives an array of even length, a number k, and pairs that use every element once.

We chose these rules. The answer is true or false. Values may be negative, from -10^9 to 10^9. There are 2 to 10^4 values. k is from 1 to 10^5. We wrote new examples.

Our version is about 85% the same as the reported question.

You are given an integer array nums with an even number of elements, and an integer k. Group all the elements in twos: every element goes into exactly one pair, so the pairs use up the whole array.

Return true if the pairs can be chosen so that the sum of every pair is divisible by k, and false otherwise. A sum may be negative or zero; for example, -6 and 0 are both divisible by 3.

Function

canPairUp(nums: int[], k: int) → boolean

Examples

Example 1

nums = [7,-3,5,11,2,-2]k = 4return = true

One way: 7 + (-3) = 4, 5 + 11 = 16 and 2 + (-2) = 0. All three sums are divisible by 4.

Example 2

nums = [5,9,2,6]k = 5return = false

5 is divisible by 5, so its partner must be divisible by 5 too, and no other value is. So no pairing works.

Example 3

nums = [-1,1]k = 7return = true

The only pair sums to 0, and 0 is divisible by every k.

Constraints

  • 2 <= nums.length <= 10^4, and nums.length is even.
  • -10^9 <= nums[i] <= 10^9
  • 1 <= k <= 10^5

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

  • Filter Paginated Medical RecordsNVIDIA · PHONE SCREENNVIDIA interview questions
  • Count Product-Divisible PairsMotive · PHONE SCREENMotive interview questions
  • Employee Count Median, Mean and ModeClay · PHONE SCREEN
  • Max Points on a LineUber · PHONE SCREENUber interview questions
  • Average Grades per StudentHartford Financial Services · PHONE SCREENHartford Financial Services interview questions
  • Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
  • Count Subarrays with a Perfect-Square ProductMicrosoft · OAMicrosoft interview questions
  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
  • Get Triplet CountIBM · OAIBM interview questions
  • Group-Relative Policy AdvantagesAmazon · ONSITE INTERVIEW

Interview reports that mention this question

  • Adobe New Grad MTS Interview Questions: 7 Experiences

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 ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)
  • Adobe Product Intern Interviews: 15 Experiences (Part 3 of 4)
All Adobe interview questionsSee Adobe hiring insights
Saved
class Solution {
    public boolean canPairUp(int[] nums, int k) {
        // Write your code here.
    }
}
Checking account…