# Leetcode 2141: Maximum Running Time of N Computers

3 min readJan 20, 2022

--

In this problem, we try to figure out how long we can run `n`

computers using a list of batteries. We have to use `n`

different batteries at any moment and switching them can be done any time (as long as it is a whole minute). Each battery has a set number of minutes that it can be used for.

You have

`n`

computers. You are given the integer`n`

and a0-indexedinteger array`batteries`

where the`ith`

battery canruna computer for`batteries[i]`

minutes. You are interested in runningall`n`

computerssimultaneouslyusing the given batteries.

Initially, you…