FastPrepTwo Positions That Add Up to a Target
Problems/Two Positions That Add Up to a Target

Two Positions That Add Up to a Target

DocuSign logoDocuSign● EasyINTERNPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Three reports mention this pair-sum task. One, from November 2018, calls an onsite question a variant of it without saying what changed. One, from March 2019, tells it as a story about rafter cut angles that must add up to a roof's ridge angle. One, from September 2026, lists it as a coding interview question.

The reports give no input format, limits or examples. Here you get an array and a target. Exactly one pair fits, and you return its two positions, smaller first. The editorial retells the rafter story, and it is not part of the task. We wrote the examples.

Our version is about 85% the same as the reported questions.

You are given an integer array values and an integer target. Find two different positions i and j where values[i] + values[j] == target.

  • Exactly one such pair of positions exists.
  • Two equal values at different positions may form the pair, but one position cannot be used twice.

Return the two positions as [i, j] with i < j. Positions start at 0.

Function

pairPositionsForTarget(values: int[], target: int) → int[]

Examples

Example 1

values = [6,-1,4,9,2]target = 13return = [2,3]

4 is at position 2 and 9 is at position 3, and 4 + 9 = 13. No other pair adds up to 13, so the answer is [2,3].

Example 2

values = [5,3,5]target = 10return = [0,2]

The value 5 sits at positions 0 and 2, and 5 + 5 = 10. The same position cannot be used twice, but two equal values at different positions are fine. The answer is [0,2].

Example 3

values = [-4,8]target = 4return = [0,1]

With two numbers there is only one pair: -4 + 8 = 4. The answer is [0,1].

Constraints

  • 2 <= values.length <= 10^4
  • -10^8 <= values[i] <= 10^8
  • -2 * 10^8 <= target <= 2 * 10^8
  • Exactly one pair of positions i < j has values[i] + values[j] == target.

More DocuSign Phone Screen questions

  • Symmetric Binary TreePHONE SCREEN · Seen Oct 2026
  • Union Area of Two RectanglesPHONE SCREEN · Seen Oct 2026
  • Execute Cursor-Based Text Editor OperationsPHONE SCREEN · Seen Sep 2026
  • Minimize Array Sum After K Halving OperationsPHONE SCREEN · Seen Sep 2026
  • Fizz and Buzz Words From 1 to nPHONE SCREEN · Seen Sep 2026
  • Rain Kept Between WallsPHONE SCREEN · Seen Mar 2026
  • Exact Palindrome CheckPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2022
  • Reverse the Characters of a TextPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2022
  • Rebuild a Trip From Flight TicketsPHONE SCREEN · Seen Apr 2019
  • Find the Words for Each PrefixPHONE SCREEN · Seen Sep 2018

Similar questions at other companies

  • Majority ElementByteDance · PHONE SCREENByteDance interview questions
  • Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
  • Recommend Films from Viewers Who Watched Everything You DidBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Find Unique ElementsCisco · PHONE SCREENCisco interview questions
  • Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Two SumAmazon · OA · PHONE SCREEN
  • Employee Count Median, Mean and ModeClay · PHONE SCREEN
  • Two SumBNSF Railway · PHONE SCREENBNSF Railway interview questions
  • List the Key and Value of Every Map EntryNewgen Software · ONSITE INTERVIEW
  • Pizza Price CalculatorMicrosoft · ONSITE INTERVIEWMicrosoft interview questions

Interview reports that mention this question

  • DocuSign SWE Intern Interviews: 27 Experiences (Part 2 of 2)
  • DocuSign SWE Intern OA Questions: 53 Experiences (Part 1 of 2)
All DocuSign interview questionsSee DocuSign hiring insights
Saved
class Solution {
    public int[] pairPositionsForTarget(int[] values, int target) {
        // Write your code here.
    }
}
Checking account…