FastPrepPhone Battery Discharge Scheduling
Problems/Phone Battery Discharge Scheduling

Phone Battery Discharge Scheduling

Roblox logoRoblox● MediumFULLTIMEOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: I re-audited the available legacy author-written Roblox reports and could not find an original report supporting this cyclic battery and recharge task. Its current Roblox attribution, statement, role, stage, signature, examples, constraints, and edge cases therefore have a 0% match to verified source material. The page is retained for continuity, but it should be treated as an independently authored practice exercise rather than a source-backed Roblox interview question.

A dead phone needs to run for t minutes of usage time. You have n spare batteries indexed 0 to n - 1, all fully charged at the start. Battery i provides capacity[i] minutes of phone runtime; after it is fully drained it needs recharge[i] minutes of real-time to be ready again.

Batteries must be used in strict cyclic order: 0, 1, 2, ..., n - 1, 0, 1, .... You cannot skip a battery: if the next one in line is still recharging when its turn comes, the phone sits dead (off) until that battery is ready. Phone usage time does not advance while the phone is off; only real-time advances, allowing the other batteries to keep recharging on their own schedules. Once a battery is inserted, the phone runs on it continuously until it is fully drained or the phone hits its t-minute target — you cannot pop a battery out partway through to insert the next one.

Return the indices of the batteries that were fully discharged within the t minutes of usage, in the order they discharged. If the last battery used was only partially drained when the phone hit its t-minute target, it is not included.

Function

batteryDischargeOrder(t: int, capacity: int[], recharge: int[]) → int[]

Examples

Example 1

t = 10capacity = [3, 4, 2]recharge = [5, 6, 8]return = [0, 1, 2]

Battery 0 runs from real-time 0 to 3 (full discharge), battery 1 from 3 to 7 (full discharge), battery 2 from 7 to 9 (full discharge). At real-time 9, battery 0 is back (recharged at 8) and runs for 1 more minute before the phone hits 10 minutes of usage. That is a partial use, so battery 0's second turn is not counted.

Example 2

t = 10capacity = [5]recharge = [5]return = [0, 0]

Battery 0 runs 0..5 (full discharge, ready again at real-time 10). The phone is off from real-time 5 to 10. At real-time 10, battery 0 runs another 5 minutes (full discharge), bringing usage to 10. Battery 0 is fully discharged twice.

Example 3

t = 4capacity = [5]recharge = [10]return = []

Battery 0 provides 5 minutes of capacity but only 4 are used before the phone hits the runtime target. It is only partially drained, so it is never fully discharged and the result is empty.

Constraints

  • 1 <= t <= 10^4
  • 1 <= capacity.length == recharge.length <= 10^3
  • 1 <= capacity[i] <= 10^4
  • 0 <= recharge[i] <= 10^4

More Roblox interview questions

  • Design Search Autocomplete SystemPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Most Frequent Call Path From Function Trace LogsPHONE SCREEN · Seen Nov 2026
  • Candy Crush Grid Matching and GravityPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Implement a Rate LimiterPHONE SCREEN · Seen Oct 2026
  • Rate Limit by Multiple Request FieldsPHONE SCREEN · Seen Oct 2026
  • Topological Sort with Secondary OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Time-Aware Search AutocompletePHONE SCREEN · Seen Oct 2026
  • Centered Block Placement QueriesOA · Seen Oct 2026
  • Most Frequent Call Stack Per ThreadPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Robot Navigation Around LasersOA · Seen Oct 2026

Similar questions at other companies

  • Bank Accounts with Balance HistoryMeta · OAMeta interview questions
  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Repeated Mirror XORMathWorks · OAMathWorks interview questions
  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
  • Stabilize Student Test ScoresVirtu Financial · OAVirtu Financial interview questions
  • Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Minimize Task Resource ConsumptionNVIDIA · OANVIDIA interview questions
  • Index of the Maximum After Left RotationsChubb · OAChubb interview questions
  • Leaves Remaining After WindCresta · OACresta interview questions
  • Rolling MetricsAkuna Capital · OAAkuna Capital interview questions

Interview reports that mention this question

  • Roblox OA: What It Tests (2026)

Roblox interview experiences

  • Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)
  • Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)
  • Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)
  • Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
  • Roblox New Grad Games and BQ: 25 Experiences (Part 3 of 7)
All Roblox interview questionsSee Roblox hiring insights
Saved
class Solution {
    public int[] batteryDischargeOrder(int t, int[] capacity, int[] recharge) {
      // write your code here
    }
}
Checking account…