PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

Practice a Amazon coding interview problem focused on find the closest version by date. The prompt emphasizes edge cases, clean implementation, and verifiable test behavior without revealing the solution.

  • hard
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Find the Closest Version by Date

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Onsite

Given a target date and versions as `(version_name, release_date)`, return the version whose date is closest to the target. Dates use `YYYY-MM-DD`. If two dates tie, choose the earlier release date. Implement: ```python def closest_version(target_date: str, versions: list[tuple[str, str]]) -> str: pass ```

Quick Answer: Practice a Amazon coding interview problem focused on find the closest version by date. The prompt emphasizes edge cases, clean implementation, and verifiable test behavior without revealing the solution.

Return the version whose release date is closest to a target date, choosing the earlier date on ties.

Examples

Input: {"target_date":"2026-04-01","versions":[["v1","2023-04-01"],["v2","2025-04-01"],["v3","2026-05-03"]]}

Expected Output: "v3"

Explanation: Closest date.

Input: {"target_date":"2024-01-10","versions":[["a","2024-01-01"],["b","2024-01-19"]]}

Expected Output: "a"

Explanation: Tie chooses earlier date.

Input: {"target_date":"2024-01-10","versions":[["a","2024-01-10"]]}

Expected Output: "a"

Explanation: Exact match.

Input: {"target_date":"2024-01-10","versions":[]}

Expected Output: ""

Explanation: No versions.

Input: {"target_date":"2024-02-29","versions":[["leap","2024-02-29"],["next","2024-03-01"]]}

Expected Output: "leap"

Explanation: Leap date.

Input: {"target_date":"2024-01-10","versions":[["future","2025-01-10"],["past","2023-01-10"]]}

Expected Output: "past"

Explanation: Tie by earlier date.

Input: {"target_date":"2024-06-15","versions":[["x","2024-06-20"],["y","2024-06-16"]]}

Expected Output: "y"

Explanation: Near future.

Input: {"target_date":"2024-06-15","versions":[["x","2024-06-01"],["y","2024-06-10"]]}

Expected Output: "y"

Explanation: Near past.

Last updated: Jul 4, 2026

Loading coding console...

PracHub

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

Product

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

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.

Related Coding Questions

  • Find Two-Word Compound Words - Amazon (hard)
  • Minimum Path Length Through a Grid With One Allowed Cell Conversion - Amazon (medium)
  • Circular Drone Hub Delivery Route - Amazon (hard)
  • Leaf Domain Cumulative Scores - Amazon (medium)
  • Kth Largest Perfect Binary Subtree - Amazon (medium)