diff --git a/codes/javascript/chapter_computational_complexity/leetcode_two_sum.js b/codes/javascript/chapter_computational_complexity/leetcode_two_sum.js index 7629dd3c4..4fe58a433 100644 --- a/codes/javascript/chapter_computational_complexity/leetcode_two_sum.js +++ b/codes/javascript/chapter_computational_complexity/leetcode_two_sum.js @@ -2,7 +2,7 @@ * @Author: gyt95 (gytkwan@gmail.com) * @Date: 2022-12-15 10:51:54 * @Last Modified by: gyt95 (gytkwan@gmail.com) - * @Last Modified time: 2022-12-15 23:40:09 + * @Last Modified time: 2022-12-16 00:00:35 */ /** @@ -33,4 +33,13 @@ function twoSumHashTable(nums, target) { m[target - nums[i]] = i; } } -} \ No newline at end of file +} + +/* Driver Code */ +let nums = [2, 7, 11, 15] +twoSumBruteForce(nums) +console.log("使用暴力枚举后得到结果:", nums) + +let nums1 = [2, 7, 11, 15] +twoSumHashTable(nums1) +console.log("使用辅助哈希表后得到结果", nums1)