FastPrepTrim a Telemetry Buffer to a Target Sum
Problems/Trim a Telemetry Buffer to a Target Sum

Trim a Telemetry Buffer to a Target Sum

Amazon logoAmazon● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Amazon full-time onsite interview. The report gave the goal of removing from the ends, the limits, and one example that is consistent. A second report gave a number that does not fit those rules. Our version follows the clearly stated rules for removing from the ends, and under them that case needs five operations. Our version is about 96% the same as the reported question.

An embedded device stores positive sensor readings in readings. In one operation, it may permanently remove either the oldest reading at the left end or the newest reading at the right end.

Return the minimum number of operations whose removed values sum to exactly x. Return -1 when no sequence of endpoint removals reaches exactly x.

Function

minTelemetryRemovals(readings: int[], x: int) → int

Examples

Example 1

readings = [1,1,4,2,3]x = 5return = 2

Remove 3 and then 2 from the right end.

Example 2

readings = [5,6,7,8,9]x = 4return = -1

No combination of removals from the two ends totals 4.

Example 3

readings = [3,2,20,1,1,3]x = 10return = 5

Keeping only the middle value 20 removes a total of 10 using five endpoint operations.

Constraints

  • 1 <= readings.length <= 100000
  • 1 <= readings[i] <= 10000
  • 1 <= x <= 1000000000

Source note: The source image is a source-neutral excerpt of the author-reported prompt, including the preserved conflicting numeric answer.

More Amazon Onsite Interview questions

  • Assign Escalations to TeamsONSITE INTERVIEW · Seen Nov 2026
  • Best Time to Buy and Sell StockONSITE INTERVIEW · Seen Nov 2026
  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximum Earnings Across WarehousesONSITE INTERVIEW · Seen Nov 2026
  • Priority Message BufferONSITE INTERVIEW · Seen Nov 2026
  • Search in a Rotated Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent ElementsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximal SquareONSITE INTERVIEW · Seen Nov 2026
  • Serialize and Deserialize a Binary TreeONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Shortest Window with Required CountsOracle · ONSITE INTERVIEWOracle interview questions
  • Longest Binary Window with at Most K OnesLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Count Hotspot Playback WindowsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Subarray with a Given SumExpedia · ONSITE INTERVIEWExpedia interview questions
  • Count Subarrays With Product Equal to KSalesforce · OASalesforce interview questions
  • Subarray Product Less Than KApple · PHONE SCREENApple interview questions
  • Subarray Product Less Than KAngel One · PHONE SCREEN
  • Subarray Product Less Than KThe D.E. Shaw Group · PHONE SCREENThe D.E. Shaw Group interview questions
  • Count Belt Sections With K Fruit Pairs (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Max Consecutive Ones IIINykaa · PHONE SCREENNykaa interview questions

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE Onsite Interview Questions: 9 Experiences
  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)
  • Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)
  • Amazon New Grad OA Problems: Every Task We Have (Part 3 of 5)
See Amazon hiring insights
Saved
class Solution {
    public int minTelemetryRemovals(int[] readings, int x) {
      // Write your code here.
    }
}
Checking account…