PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Amazon

Solve interval deletion and GCD subarray problems

Last updated: Mar 29, 2026

Quick Overview

This question evaluates algorithm design and complexity-analysis skills across interval manipulation and number-theoretic array operations, testing competency in reasoning about interval coverage and deletions as well as GCD properties and subarray modification under constraints.

  • Medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Solve interval deletion and GCD subarray problems

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

1) Given n closed intervals [li, ri] on a number line, remove the fewest intervals so that among the remaining intervals there exists at least one interval that fully covers all other remaining intervals (i.e., there is [L, R] such that for every remaining [l, r], L <= l and r <= R). Return the minimum number of deletions required and describe an algorithm with time and space complexity. 2) Given an integer array nums and an integer k (maximum number of elements you may change within a chosen subarray), find the minimum length of a contiguous subarray such that, after modifying at most k elements inside that subarray to any positive integers of your choice, the subarray’s greatest common divisor is greater than 1. Return the minimal length and outline an efficient approach. Example: nums = [2, 2, 4, 9, 6], k = 1 -> output 1.

Quick Answer: This question evaluates algorithm design and complexity-analysis skills across interval manipulation and number-theoretic array operations, testing competency in reasoning about interval coverage and deletions as well as GCD properties and subarray modification under constraints.

Related Interview Questions

  • Count Connected Components in an Undirected Graph - Amazon (medium)
  • Find Unique Target-Sum Pairs - Amazon (easy)
  • Find Valid IP Addresses in Files - Amazon (medium)
  • Implement Optimal Bucket Batching - Amazon (hard)
  • Implement Cache and Rotate Matrix - Amazon (medium)
Amazon logo
Amazon
Jul 16, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0
  1. Given n closed intervals [li, ri] on a number line, remove the fewest intervals so that among the remaining intervals there exists at least one interval that fully covers all other remaining intervals (i.e., there is [L, R] such that for every remaining [l, r], L <= l and r <= R). Return the minimum number of deletions required and describe an algorithm with time and space complexity.
  2. Given an integer array nums and an integer k (maximum number of elements you may change within a chosen subarray), find the minimum length of a contiguous subarray such that, after modifying at most k elements inside that subarray to any positive integers of your choice, the subarray’s greatest common divisor is greater than 1. Return the minimal length and outline an efficient approach. Example: nums = [2, 2, 4, 9, 6], k = 1 -> output 1.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

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

Master your tech interviews with 7,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
  • Compare Platforms
  • Discord Community

Support

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

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.