title: Determining Time and Space Complexity of program
body: <p>So I had a coding challenge for an internship and part of it was to determine the space and time complexity of my program. The program was roughly as follows.</p>
  
  <pre><code>while(A){
    int[][] grid;
    // additional variables
  
   while(B){ //for loop involves iterating through grid
    // additional variables
    for(...) 
      for(....)
   }
  
    for(...) //for loop involves iterating through grid
      for(....)
  }
  </code></pre>
  
  <p>So what I said was that the program overall has time complexity of (A<em>N^2+B</em>N^2), therefore concluding that it has an amortized time of O(N^2).</p>
  
  <p>As for the space complexity, was I supposed to sum the number space used by all variables? Assuming every variable is an int and there is 3 in loop A and two in loop B would the space complexity be (A*24 + B*16)?</p>