Update codes/typescript/chapter_computational_complexity/time_complexity.ts
Co-authored-by: Justin Tse <xiefahit@gmail.com>
This commit is contained in:
parent
abdf1f3117
commit
c5a9eea0a9
@ -20,7 +20,7 @@ function linear(n: number): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 线性阶(遍历数组) */
|
/* 线性阶(遍历数组) */
|
||||||
function arrayTraversal(nums: number[]) {
|
function arrayTraversal(nums: number[]): number {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
// 循环次数与数组长度成正比
|
// 循环次数与数组长度成正比
|
||||||
for (let i = 0; i < nums.length; i++) {
|
for (let i = 0; i < nums.length; i++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user