PracHub
QuestionsLearningGuidesInterview Prep
|Home/Coding & Algorithms/Upstart

Find the Minimum Absolute Difference

Last updated: Jul 28, 2026

Quick Overview

Find the smallest absolute difference between values at two distinct positions without changing the caller's list. Cover duplicates, negative and very large integers, correctness reasoning, time and space complexity, all-minimum-pair output, and online-update follow-ups.

  • medium
  • Upstart
  • Coding & Algorithms
  • Software Engineer

Find the Minimum Absolute Difference

Company: Upstart

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

# Find the Minimum Absolute Difference Implement `minimum_absolute_difference(values)`. Given at least two integers, return the smallest absolute difference between any two distinct positions in the list. Duplicate values are allowed, in which case the answer is zero. Do not mutate the caller's list. ## Constraints - `2 <= len(values) <= 200000` - `-10^18 <= values[i] <= 10^18` ## Examples - `[1, 20, 100, 3]` returns `2`. - `[8, -1, 8]` returns `0`. ## Clarifications Explain why, after an appropriate ordering, the closest pair must be adjacent. Include time and auxiliary-space complexity. ## Hints Ordering the values removes the need to compare every pair. ## Extensions - Return every pair attaining the minimum. - Maintain the answer under online insertions. - Generalize to points in two dimensions.

Quick Answer: Find the smallest absolute difference between values at two distinct positions without changing the caller's list. Cover duplicates, negative and very large integers, correctness reasoning, time and space complexity, all-minimum-pair output, and online-update follow-ups.

Related Interview Questions

  • Sum Multiples of Three, Five, or Seven - Upstart (medium)
  • Count Words in Lexicographic Order - Upstart (medium)
  • Add Dramatic Punctuation to Text - Upstart (medium)
  • Interleave Three Equal-Length Strings - Upstart (easy)
|Home/Coding & Algorithms/Upstart

Find the Minimum Absolute Difference

Upstart logo
Upstart
Jul 27, 2026, 12:00 AM
mediumSoftware EngineerTake-home ProjectCoding & Algorithms
0
0

Find the Minimum Absolute Difference

Implement minimum_absolute_difference(values). Given at least two integers, return the smallest absolute difference between any two distinct positions in the list.

Duplicate values are allowed, in which case the answer is zero. Do not mutate the caller's list.

Constraints

  • 2 <= len(values) <= 200000
  • -10^18 <= values[i] <= 10^18

Examples

  • [1, 20, 100, 3] returns 2 .
  • [8, -1, 8] returns 0 .

Clarifications

Explain why, after an appropriate ordering, the closest pair must be adjacent. Include time and auxiliary-space complexity.

Hints

Ordering the values removes the need to compare every pair.

Extensions

  • Return every pair attaining the minimum.
  • Maintain the answer under online insertions.
  • Generalize to points in two dimensions.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Upstart•More Software Engineer•Upstart Software Engineer•Upstart Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.