FastPrepLongest Continuous Subarray Within an Absolute-Difference Limit
Problems/Longest Continuous Subarray Within an Absolute-Difference Limit

Longest Continuous Subarray Within an Absolute-Difference Limit

Oracle logoOracle● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Oracle phone screen. The report gives the main task and the interview setting. We rebuilt the function signature, a fixed order for the output, the examples, and the input limits to stay close to the report. We think our version is about 90% the same as the reported question.

Given an integer array and a nonnegative limit, return the maximum length of a nonempty contiguous subarray whose maximum and minimum values differ by at most limit. Return 0 for an empty array.

Function

longestSubarrayWithinLimit(nums: int[], limit: int) → int

Examples

Example 1

nums = [8,2,4,7]limit = 4return = 2

The longest valid window has length two.

Example 2

nums = [10,1,2,4,7,2]limit = 5return = 4

The window [2,4,7,2] has range five.

Example 3

nums = [4,2,2,2,4,4,2,2]limit = 0return = 3

The longest constant run has length three.

Constraints

  • 0 <= nums.length <= 100000.
  • 0 <= limit <= 10^9.

More Oracle Phone Screen questions

  • Remove Parentheses from a Plus-Minus ExpressionPHONE SCREEN · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · Seen Oct 2026
  • Shortest Window by Distinct-Value SumPHONE SCREEN · Seen Oct 2026
  • Detect a Cycle in a Directed GraphPHONE SCREEN · Seen Oct 2026
  • Time-Based Key-Value StorePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Remove Adjacent Duplicates in String IIPHONE SCREEN · Seen Oct 2026
  • Sum Root-to-Leaf Binary NumbersPHONE SCREEN · Seen Oct 2026
  • Longest All-Present Attendance StreakPHONE SCREEN · Seen Oct 2026
  • Next PermutationPHONE SCREEN · Seen Sep 2026
  • Valid ParenthesesPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Disk Space Window AnalyzerAgoda · PHONE SCREENAgoda interview questions
  • Transcript Window MetricsSesame · PHONE SCREEN
  • Sliding Window MaximumAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Sliding Window MaximumGroww · PHONE SCREEN
  • Largest Value in Every Sliding WindowAdobe · PHONE SCREENAdobe interview questions
  • Sliding Window MaximumBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Sliding Window Average (Meta Canada, E4/E5 :)Meta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Sliding Window MaximumNVIDIA · PHONE SCREENNVIDIA interview questions
  • Longest Subarray Within an Absolute-Difference LimitGoogle · ONSITE INTERVIEWGoogle interview questions
  • Longest Continuous Subarray Within an Absolute-Difference LimitUber · ONSITE INTERVIEWUber interview questions

Oracle interview experiences

  • Oracle SWE Onsite Interview Experience: 1 Experience
All Oracle interview questionsSee Oracle hiring insights
Saved
class Solution {
    public int longestSubarrayWithinLimit(int[] nums, int limit) {
        // write your code here
    }
}
Checking account…