FastPrepDetect a Server RAM Capacity Breach
Problems/Detect a Server RAM Capacity Breach

Detect a Server RAM Capacity Breach

Myntra logoMyntra● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Myntra onsite interview for interns. The report gives RAM usage, start times, end times, and a decision on whether capacity is breached. It names difference-array, prefix-sum, and sweep-line techniques. It leaves out how interval ends count, tie behavior, the limits, and the examples. We filled those in.

Our version is about 92% the same as the reported question.

A server cluster runs jobs described by parallel arrays ram, startTimes, and endTimes. Job i consumes ram[i] units during the half-open interval [startTimes[i], endTimes[i]).

Return true if the total RAM used by active jobs is ever strictly greater than totalCapacity. Otherwise, return false. A job ending at a time releases its RAM before any job starting at that same time becomes active.

Function

exceedsRamCapacity(ram: long[], startTimes: int[], endTimes: int[], totalCapacity: long) → boolean

Examples

Example 1

ram = [4,3,5]startTimes = [1,2,6]endTimes = [5,7,8]totalCapacity = 6return = true

From time 2 through time 5, the first two jobs use 7 units, which exceeds 6.

Example 2

ram = [4,3,2]startTimes = [1,5,5]endTimes = [5,7,6]totalCapacity = 5return = false

At time 5, the 4-unit job has ended before the 3-unit and 2-unit jobs start, so usage reaches but never exceeds 5.

Constraints

  • 0 <= ram.length <= 2 * 10^5.
  • ram.length == startTimes.length == endTimes.length.
  • 1 <= ram[i] <= 10^9.
  • 0 <= startTimes[i] < endTimes[i] <= 10^9.
  • 1 <= totalCapacity <= 10^18.

More Myntra interview questions

  • Minimum Route Reversals to Warehouse ZeroONSITE INTERVIEW · Seen May 2026
  • Minimum Swaps to Group Values at Most KONSITE INTERVIEW · Seen May 2026
  • Smallest Binary-Digit MultipleONSITE INTERVIEW · Seen May 2026
  • Maximum Capped Histogram Area After One RemovalOA · Seen May 2026

Similar questions at other companies

  • Meeting Scheduling SystemHevo Data · ONSITE INTERVIEW
  • Peak Task Concurrency IntervalsGoogle · ONSITE INTERVIEW
  • Peak Chat Load Across AgentsCresta · PHONE SCREEN
  • Majority Labels over Audio IntervalsNooks · PHONE SCREEN
  • Brightest Position on a StreetCapital One · OA
  • Merge IntervalsApple · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Merge Overlapping IntervalsAtlassian · PHONE SCREEN · ONSITE INTERVIEW
  • Maximum Concurrent Processes (Bar Raiser Round)Amazon · PHONE SCREEN · ONSITE INTERVIEW
  • Maximum Intervals Overlapping a Fixed-Length WindowBooking.com · ONSITE INTERVIEW
  • Meeting Rooms IISalesforce · ONSITE INTERVIEW
See Myntra hiring insights
Saved
class Solution {
    public boolean exceedsRamCapacity(long[] ram, int[] startTimes, int[] endTimes, long totalCapacity) {
        // Return true exactly when active RAM usage exceeds capacity.
    }
}
Checking account…