Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Two Sum Boolean

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

Your question is Two Sum Boolean. 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

Guidewire policy workflows may need to verify whether two integer values from a claim or policy calculation can combine to a specified threshold. Given an unsorted array of integers and a target integer, return True if two distinct elements sum exactly to the target. Otherwise, return False.

Each array element may be used at most once, so a single value cannot satisfy the requirement by pairing with itself unless it appears at least twice.

Formal Specification

Implement has_pair_with_sum(nums, target).

  • Input: nums, a list of integers, and target, an integer.
  • Output: A boolean indicating whether any two different positions in nums contain values whose sum equals target.
  • The input array is not sorted, and the function must not modify it.

Constraints

  • 0 <= nums.length <= 100,000
  • -10^9 <= nums[i] <= 10^9
  • -10^9 <= target <= 10^9
  • The input array must not be modified

Function Signature

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