Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Longest Stable GPU Utilization Window

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Longest Stable GPU Utilization Window. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Given an integer array utilization where each value represents GPU utilization percentage sampled over time, and an integer limit, return the length of the longest contiguous subarray in which the difference between the maximum and minimum values is less than or equal to limit. The input is a list of integers, and the output is a single integer.

Constraints

  • 1 <= utilization.length <= 10^5
  • 0 <= utilization[i] <= 100
  • 0 <= limit <= 100

Function Signature

def longest_stable_window(utilization, limit):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output