Posted Updated a few seconds read (About 58 words)
CodeInterview
BigO
- 時間複雜度相加還是相乘
相加1 2 3 4 5 6 7 8
| Add the Runtimes: 0 (A + B) 1 for (int a : arrA) { 2 print(a); 3 } 4 5 for (int b : arrB) { 6 print(b) ; 7 }
|
相乘:
1 2 3 4 5 6
| Multiply the Runtimes: O(A* B) 1 for (int a : arrA) { 2 for (int b : arrB) { 3 print(a + " , " + b); 4 } 5 }
|