For the first method, it is n*n = n^2. Since there are two loops, for each loop
O(n) is n since you are going through each item in an array.
Second one is a constant o(1).
1
solved How to calculate Big-O? [closed]
For the first method, it is n*n = n^2. Since there are two loops, for each loop
O(n) is n since you are going through each item in an array.
Second one is a constant o(1).
1
solved How to calculate Big-O? [closed]