Traverse column-by-column:
- A
Outer i, inner j
- B
Use for-each
- C
Cannot do
- Dcheck_circle
Outer j (cols), inner i (rows)
Explanation
Swap outer and inner: outer iterates columns.
AP Computer Science A· difficulty 3/5
Traverse column-by-column:
Outer i, inner j
Use for-each
Cannot do
Outer j (cols), inner i (rows)
Explanation
Swap outer and inner: outer iterates columns.
Want 10 more like this — adaptive to your weak spots?
For the 4x4 matrix shown: <code class="language-java"int s = 0; for (int i = 0; i < m.length; i++) s += m[i][m.length - 1 - i]; </code</pre What is <codes</code…
chevron_rightAnti-diagonal of n×n matrix:…
chevron_rightFor m = {{1,2,3},{4,5,6},{7,8,9}}, what is the sum of m[i][i] for i=0..2?…
chevron_right