title: Help deciphering this code and it's runtime
body: <pre><code>int[][] A = new int [n][];
  for (int i=0; i&lt;n; i++) {
      if (i % 2 == 0) // i is a multiple of 2
          A[i] = new int [n];
      else
          A[i] = new int [1];
  }
  
  for (int i=0; i&lt;A.length; i++)
      for (int j=0; j&lt;A[i].length; j++)
          sum = sum + A[i][j];
  </code></pre>
  
  <p>So I'm getting a bit confused on what the arrays are doing. The first line initializes a 2D array with n columns. The first for loops looks at each column. If it is an even column, it will put n in the first row of that column. Now I'm a bit confused at this because it is being referenced with only one bracket even though it should be a 2D array. The same thing with the double for loops. What is the difference between A.length and A[i].length? From what I understand, the double for loops are iterating through the array and getting the sum of all the elements. Can someone clarify this because I'm a bit lost on the syntax. </p>
  
  <p>Also, my instinct says that this code runs in O(n^2) time at the very least because of the double for loops. Does that seem right?</p>