mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-19 12:24:34 +08:00
Update worst_best_time_complexity,
leetcode_two_sum
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
* Author: gyt95 (gytkwan@gmail.com)
|
||||
*/
|
||||
|
||||
/* 方法一:暴力枚举 */
|
||||
function twoSumBruteForce(nums, target) {
|
||||
const n = nums.length;
|
||||
// 两层循环,时间复杂度 O(n^2)
|
||||
@ -17,6 +18,7 @@ function twoSumBruteForce(nums, target) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/* 方法二:辅助哈希表 */
|
||||
function twoSumHashTable(nums, target) {
|
||||
// 辅助哈希表,空间复杂度 O(n)
|
||||
let m = {};
|
||||
|
Reference in New Issue
Block a user