title: Time and Space complexity of the max disk space
body: <pre><code>from collections import deque
  def findMax(hardDiskSpace, k):
      n = len(hardDiskSpace)
      if n * k == 0:
          return []
      if k &gt; n:
          return []
  
      deq = deque()
      res = []
      i = 0
      while i &lt; n:
          if deq and deq[0] == i - k:
              deq.popleft()
          while deq and hardDiskSpace[deq[-1]] &gt; hardDiskSpace[i]:
              deq.pop()
          deq.append(i)
  
          if i &gt;= k - 1:
              res.append(hardDiskSpace[deq[0]])
          i += 1
      print(res)
      print(max(res))
  
  
  if __name__ == '__main__':
      hdd = [62, 64, 77, 75, 71, 60, 79, 75]
      k = 4
      findMax(hdd, k)
  </code></pre>
  <p>A Company performing an analysis on the computers at one of its offices. The computers are spaced along a single row.
  The analysis is performed in the following way:
  Choose a contiguous segment of a certain number of computers, starting from the beginning of the row.
  Analyze the available hard disk space on each of the computers. Determine the minimum available disk space within this segment.
  After performing these steps for the first segment, it is then repeated for the next segment, continuing this procedure until the end of the row (i.e. if the segment size is 4, computers 1 to 4 would be analyzed, then 2 to 5, etc.)
  Given this analysis procedure, write an algorithm to find the maximum available disk space among all the minima that are found during the analysis.
  <br>
  <strong>Input</strong><br>
  The input consists of three arguments:<br>
  <strong>numComputer</strong>: an integer representing the number of computers<br>
  <strong>hardDiskSpace</strong>: a list of integers representing the hard disk space of the computers<br>
  <strong>segmentLength</strong>: an integer representing the length of the contiguous segment of computers to be considered in each iteration<br>
  <br>
  <strong>Output</strong><br>
  Return an integer representing the maximum available disk space among all the minima that are found during the analysis.
  <br>
  <strong>Examples</strong>
  <br>
  <strong>Input</strong>:<br>
  numComputer = 3<br>
  hardDiskSpace = [62, 64, 77, 75, 71, 60, 79, 75]<br>
  segmentLength = 4<br>
  Output: 64<br>
  <br>
  Could anyone please explain me the time and space complexity of the above problem.</p>