FastPrepUnique Near-Equal Target-Sum Pairs
Problems/Unique Near-Equal Target-Sum Pairs

Unique Near-Equal Target-Sum Pairs

Fivetran logoFivetran● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report does not say how to handle duplicates, order, empty input, or number limits. We chose those. Our version is about 80% the same as the reported question.

Given an integer array nums and an integer target, return every unique pair of values whose sum is target and whose absolute difference is at most 1.

Each pair must use two distinct array positions. Return each pair as [a, b], where a <= b. Pairs are unique by value, so repeated occurrences do not create duplicate result pairs. An equal-value pair [a, a] is valid only when a occurs at least twice.

Sort the returned pairs lexicographically. If no pair qualifies, return an empty array.

Function

findUniquePairs(nums: int[], target: int) → int[][]

Examples

Example 1

nums = [1,4,2,3,2]target = 5return = [[2,3]]

Both [1,4] and [2,3] sum to 5, but only [2,3] has an absolute difference at most 1. The repeated 2 does not duplicate the value pair.

Example 2

nums = [2,2,1,3]target = 4return = [[2,2]]

The two different positions containing 2 form [2,2]. Although [1,3] also sums to 4, its absolute difference is 2.

Example 3

nums = [-3,-1,-2,0]target = -3return = [[-2,-1]]

The pair [-2,-1] sums to -3 and its absolute difference is 1.

Example 4

nums = [1,5,9]target = 10return = []

The values 1 and 9 sum to 10, but their absolute difference is greater than 1. The value 5 occurs only once, so [5,5] cannot be formed.

Constraints

  • 0 <= nums.length <= 2 * 10^5
  • -10^9 <= nums[i] <= 10^9
  • -2 * 10^9 <= target <= 2 * 10^9

More Fivetran interview questions

  • Connected GroupsONSITE INTERVIEW · Seen Jun 2024
  • Reschedule Meetings for Maximum Free TimeOA · Seen Nov 2026
  • Execute In-Memory SQL Storage OperationsPHONE SCREEN · Seen Sep 2026
  • Aladdin and the Magic CarpetPHONE SCREEN · Seen Jun 2025
  • Minimum Fuel Car AlignmentPHONE SCREEN · Seen Jun 2023

Similar questions at other companies

  • Group-Relative Policy AdvantagesAmazon · ONSITE INTERVIEW
  • Product Total With the Cheapest PromotionInstacart · ONSITE INTERVIEWInstacart interview questions
  • Equation Tuple CombinationZoox · ONSITE INTERVIEW
  • Minimum Unique Card Suffix LengthBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Count Pairs Divisible by KApple · ONSITE INTERVIEWApple interview questions
  • Digit-Reversed Pairs in an ArrayExpedia · ONSITE INTERVIEWExpedia interview questions
  • Max Points on a LineLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Majority ElementMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Count Index Pairs with Equal Value OffsetGoogle · ONSITE INTERVIEWGoogle interview questions
  • Net Position Calculation from API SnapshotsHeadlands Technologies · ONSITE INTERVIEWHeadlands Technologies interview questions

Interview reports that mention this question

  • Fivetran SDE 2 Java and Concurrency Interviews: 1 Experience

Fivetran interview experiences

  • Fivetran Staff SRE Hiring Manager Interview: 1 Experience
  • Fivetran Software Engineer HackerRank and Java: 1 Experience
  • Fivetran Senior SRE Interview Process: 1 Experience
  • Fivetran Software Engineer HashMap and Design: 1 Experience
  • Fivetran SDE-2 Coding and Parking Lot Design: 1 Experience
All Fivetran interview questionsSee Fivetran hiring insights
Saved
class Solution {
    public int[][] findUniquePairs(int[] nums, int target) {
        // Write your code here
    }

}
Checking account…