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 }
  • 遞迴的時間複雜度
Author

Steven

Posted on

2023-10-10

Updated on

2025-01-14

Licensed under

Comments