Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Array Addition Equals 10

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Array Addition Equals 10. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

For a Luxoft Singapore QA data-validation utility, identify every distinct pair of numbers in an integer array whose sum is exactly 10.

Return each pair as a two-element list [a, b], where a <= b. A pair is included only once by value, even if the same values occur at multiple indices. Each array element may be used at most once for a pair. Return the pairs sorted lexicographically. If no valid pair exists, return an empty list.

Formal Specification

Implement find_pairs(nums), where nums is a list of integers. The function returns a list of two-element lists containing all unique pairs whose values sum to 10.

Constraints

  • 0 <= len(nums) <= 100000
  • -10^9 <= nums[i] <= 10^9
  • The target sum is fixed at 10
  • Return unique pairs by value, not by index
  • Each pair must be ordered as [a, b] with a <= b

Function Signature

def find_pairs(nums):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output