Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
Find Tuples That Sum to X
00:00
5 left

Find Tuples That Sum to X

EasyPython

Problem

NiCE CXone can analyze numeric interaction metrics and flag combinations that reach a required threshold. Given an integer array nums and an integer target, return every unique pair of values whose sum equals target.

Each pair must be returned as a two-element list [a, b], where a <= b. The result must contain no duplicate value pairs and must be ordered lexicographically. The same array element cannot be used twice, although equal values may form a pair when they occur at least twice. Return an empty list when no pair exists. Do not modify the input array.

Formal Specification

  • Input: nums, a list of integers, and target, an integer.
  • Output: A list of unique two-element lists. Every pair must satisfy a + b == target.

Constraints

  • 0 <= nums.length <= 10^5
  • -10^9 <= nums[i], target <= 10^9
  • The input array must remain unchanged
  • Return each distinct value pair at most once

Function Signature

def find_target_pairs(nums, target):
Interviewer

Your question is Find Tuples That Sum to X. Start with the requirements in the Question tab.

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.
Code
Sign up free to run your codeLog inLn 2
Run your code to see test output here.