From 94d5de6096c25a75a7810e3a42b741d7ae753512 Mon Sep 17 00:00:00 2001 From: gyt95 Date: Thu, 15 Dec 2022 23:44:26 +0800 Subject: [PATCH] Update js code style in space_time_tradeoff.md --- .../space_time_tradeoff.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/chapter_computational_complexity/space_time_tradeoff.md b/docs/chapter_computational_complexity/space_time_tradeoff.md index 8cbb3b5b2..140f1ef95 100644 --- a/docs/chapter_computational_complexity/space_time_tradeoff.md +++ b/docs/chapter_computational_complexity/space_time_tradeoff.md @@ -204,16 +204,16 @@ comments: true ```js title="leetcode_two_sum.js" function twoSumHashTable(nums, target) { - // 辅助哈希表,空间复杂度 O(n) - let m = {} - // 单层循环,时间复杂度 O(n) - for (let i = 0; i < nums.length; i++) { - if (m[nums[i]] !== undefined) { - return [m[nums[i]], i] - } else { - m[target - nums[i]] = i; + // 辅助哈希表,空间复杂度 O(n) + let m = {} + // 单层循环,时间复杂度 O(n) + for (let i = 0; i < nums.length; i++) { + if (m[nums[i]] !== undefined) { + return [m[nums[i]], i] + } else { + m[target - nums[i]] = i; + } } - } } ```