Target Sum Across Two Sorted Arrays
Updated
Problem statement
You are given two integer arrays first and second, each sorted in nondecreasing order, and a signed 64-bit integer target.
Return true if you can choose exactly one value from first and exactly one value from second whose sum equals target. Otherwise, return false. An empty input array therefore always produces false. Compute every candidate sum in signed 64-bit arithmetic.
Function
hasCrossArrayTargetSum(first: int[], second: int[], target: long) → booleanExamples
Example 1
first = [1,3,5]second = [2,4,8]target = 9return = trueThe values 1 and 8 form the target.
Example 2
first = []second = [1,2,3]target = 4return = falseNo pair exists when either array is empty.
Example 3
first = [2147483647]second = [2147483647]target = 4294967294return = trueThe pair sum is computed in signed 64-bit arithmetic.
Constraints
0 <= first.length, second.length <= 200000.- Both arrays are sorted in nondecreasing order.
- Every array value is a signed 32-bit integer.
-2^32 <= target <= 2^32 - 2.
More Squarepoint Capital Phone Screen questions
- Lazy Filter over a GeneratorPHONE SCREEN · Seen Nov 2026
- Moving Average of a Data StreamPHONE SCREEN · Seen Nov 2026
- Newton Square Root to a Guaranteed TolerancePHONE SCREEN · Seen Nov 2026
- Probability of Consecutive HeadsPHONE SCREEN · Seen Nov 2026
- Three Points in a Semicircle: Monte Carlo EstimatePHONE SCREEN · Seen Nov 2026
- Combine Two Index SequencesPHONE SCREEN · Seen Aug 2026
- Parse, Normalize, and Combine PolynomialsPHONE SCREEN · Seen Aug 2026
- Sorted Insertion SnapshotsPHONE SCREEN · Seen Aug 2026
- Strong and Weak Reference LifecyclePHONE SCREEN · Seen Aug 2026
- Classify Heap Addresses from a Memory SnapshotPHONE SCREEN · Seen Nov 2025
Similar questions at other companies
- Target Sum Across Two Sorted ArraysBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Find K Closest Elements in a Sorted ArrayNavi · PHONE SCREEN
- K Closest Elements in a Sorted ArrayAmazon · PHONE SCREEN
- Count Winning Dice Face PairsGoogle · PHONE SCREENGoogle interview questions
- Count Centaur Friend RequestsMeta · PHONE SCREENMeta interview questions
- Count Triples That Can Form a TriangleAdobe · PHONE SCREENAdobe interview questions
- Find the Duplicate in a Read-Only ArrayNutanix · PHONE SCREENNutanix interview questions
- Search a Row- and Column-Sorted MatrixByteDance · ONSITE INTERVIEWByteDance interview questions
- 3Sum SmallerSalesforce · ONSITE INTERVIEWSalesforce interview questions
- K Smallest Squares from a Sorted ArrayUber · ONSITE INTERVIEWUber interview questions