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
Target Value With Three Elements
00:00
5 left

Target Value With Three Elements

MediumPython

Problem

Tell me about your approach to given an array of integers, produce all ways to reach a target value using three elements. Implement three_sum_target(nums, target) to return every unique combination of three distinct array elements whose values sum to target. Return each combination in nondecreasing order, omit duplicate combinations, and return the combinations in lexicographic order.

Constraints

  • 0 <= nums.length <= 300
  • -10^9 <= nums[i] <= 10^9
  • -10^9 <= target <= 10^9
  • Each combination must use three distinct array elements
  • The output must not contain duplicate combinations

Function Signature

def three_sum_target(nums, target):
Interviewer

Your question is Target Value With Three Elements. 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.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.