mirror of
https://github.com/krahets/hello-algo.git
synced 2025-12-16 20:52:56 +08:00
Update codes/typescript/chapter_computational_complexity/time_complexity.ts
Co-authored-by: Justin Tse <xiefahit@gmail.com>
This commit is contained in:
@@ -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++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user