FastPrepFirst Five Increasing Temperature Ranges
Problems/First Five Increasing Temperature Ranges

First Five Increasing Temperature Ranges

Amazon logoAmazon● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Amazon full-time onsite interview. We kept the alert for five increasing readings and the stream of ranges. We chose how to pick the whole numbers and that you return the earliest ending index. Our version is about 84% the same as the reported question.

You are given a stream of temperature ranges in ranges. Each range covers integer temperatures and includes both of its ends.

Look at a group of five consecutive ranges, which means five ranges next to each other in the stream. You may choose one integer temperature from each range in the group. The group works if the chosen temperatures can be strictly increasing, with each one larger than the one before it.

Indexes start at zero. A group's ending index is the index of its last range. Return the earliest ending index of a group that works. Return -1 if no such group exists.

Function

firstFiveIncreasingRanges(ranges: int[][]) → int

Examples

Example 1

ranges = [[1,2],[2,4],[3,5],[4,8],[5,9]]return = 4

Choose 1, 2, 3, 4, 5 from the ranges in order. Each choice fits inside its range and is larger than the one before it. This group ends at index 4, which is the answer.

Example 2

ranges = [[5,5],[4,4],[3,3],[2,2],[1,1],[10,10]]return = -1

Each range holds only one temperature, so every choice is fixed. In both groups of five consecutive ranges, the fixed choices go down at least once. No group works, so the answer is minus one.

Constraints

  • 1 <= ranges.length <= 200000
  • Each row is [low, high] with -10^9 <= low <= high <= 10^9.
  • Selections must use five consecutive ranges and one integer from each range.

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

  • Best Time to Buy and Sell Stock IIKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Maximum Stock Profit with Unlimited TransactionsSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Jump Game IIOracle · ONSITE INTERVIEWOracle interview questions
  • Maximum Stock Profit with Transaction LimitsMeta · ONSITE INTERVIEWMeta interview questions
  • Jump Game IITripjack · ONSITE INTERVIEWTripjack interview questions
  • Return a Minimum-Coin Change BreakdownDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Most Transactions Kept Without Going NegativeDocuSign · ONSITE INTERVIEWDocuSign interview questions
  • Best Time to Buy and Sell Stock IIHeadlands Technologies · ONSITE INTERVIEWHeadlands Technologies interview questions
  • Fewest Jumps to the Last IndexC3.ai · ONSITE INTERVIEWC3.ai interview questions
  • Jump GameBloomberg LP · ONSITE INTERVIEWBloomberg LP 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 firstFiveIncreasingRanges(int[][] ranges) {
        // Write your code here.
    }
}
Checking account…