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 Bloomberg LP Phone Screen questions
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Target Sum Across Two Sorted ArraysSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
- Search a Row- and Column-Sorted MatrixByteDance · ONSITE INTERVIEWByteDance interview questions
- 3Sum SmallerSalesforce · ONSITE INTERVIEWSalesforce interview questions
- Find K Closest Elements in a Sorted ArrayNavi · PHONE SCREEN
- K Smallest Squares from a Sorted ArrayUber · ONSITE INTERVIEWUber interview questions
- K Closest Elements in a Sorted ArrayAmazon · PHONE SCREEN
- Find K Closest Elements in a Sorted ArrayLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
- 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
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)