???? ????
Two Sum ??? ???? ???? ?????. ??? ?? *?? *? ???? ? ?? ??? ???? ?? ?? ??? ???? ?? ???? ????? ?????.
?? ??
?? ?? nums? ?? ??? ???? ??? ???? ? ??? ???? ?????. ? ???? ??? ??? ???? ??? ??? ??? ? ? ??? ? ????.
??: ?? = [2, 7, 11, 15], ?? = 9
??: [0, 1]
??: nums[0] nums[1] = 2 7 = 9
?? ?? 1 ??? ??
?? ??? ?? ? ?? ?? ??? ????? ?? ?? ?? ???? ?? ? ????.
? ?? ??? ??? ???? ?? ?? ?? ?????.
const twoSum = (nums, target) => { for(let i = 0; i < nums.length; i++) { for (let j = i + 1; j < nums.length; j++) { console.log(` i is ${nums[i]} and k is ${nums[j]}`) // lets check if we add the 2 numbers if it equals target if (target === nums[i] + nums[j]) { return [i, j] } } } }; const nums = [2, 7, 11, 15]; const target = 9; console.log(twoSum(nums, target));
??? 1 ???
?? ???? O(n2)
???.- ?? ?? ?? ???? ?? ??
- ??? ?? ??? ?????
- ? ??? ?? ??? ?? ???
?? ???? O(1)
???.
1.??? ??? ??? ???? ?????
?? ?? 2 ? ????? ??? ??? ?.
? ??? ???? ?? ?? ?? ???????. ? ????? ?? ?????
- ??? ?? ?(JavaScript? ??)? ???? ? ??? ?????
- ? ??? ?? ??(?? - ?? ??)? ?????
- ?? ?? ???? ????? ?????
- ???? ? ??? ??? ? ??? ?????
- ??? ?? ?? ?? ??? ??? ?????
? ?? ???? ?? JS ??? ???? HashMap? ?? ??? ???? ????
const twoSumOptimizedRegularObject = (nums, target) => { const objectStuff = {} // write a for loop, to go through the arr for (let i = 0; i < nums.length; i++) { const complement = target - nums[i] if (complement in objectStuff) { return [objectStuff[complement],i] } objectStuff[nums[i]] = i } } const nums = [2, 7, 11, 15]; const target = 9; console.log(twoSumOptimizedRegularObject(nums, target));
? ?? ???? ??? JS? Map ??? ??? ???? ????. ?? Map ??(ES6? ???)? ???? ? ???? ??? ??? ???? ?? ?????. ?? ???? ?? ? ??? ???? Object.prototype?? ??? ???? ?? ?? JavaScript ??? ?? ??? ??? ?????.
const twoSumOptimized = (nums, target) => { const mapOfStuff = new Map() // write a for loop, to go through the arr for (let i = 0; i < nums.length; i++) { let complement = target - nums[i] if (mapOfStuff.has(complement)) { return [mapOfStuff.get(complement), i] } mapOfStuff.set(nums[i], i) } } const nums = [2, 7, 11, 15]; const target = 9; console.log(twoSumOptimized(nums, target));
??? 2 ???
?? ???? O(n)
???.- ??? ?? ?? ??
- ?? ?? O(1) ??? ?????
- ? ??? ?? ??? ?? ????? ?????
?? ???? O(n)
??? ?? ?? ?? ??? ??? ?? ????
??? ??? ??? ??? ??
????
- ? ??
- ???? ????
- ??? ???? ?????. ? ?? 1? ?? ? ?? ??? ??? ???.
? ??? Javascript? Two Sum ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

JavaScript? ??? ?? ????? ??? ?? ??? ??? ?? ?? ?? ????? ?? ???? ???? ?????. ??? ?? ???? ?? ??? ?? ??? ???? ???? ?? ?? ???? ???? ?????. ?? ??, ??? ? ?? ???? ??? (? : ??? null? ??) ?? ??? ????? ??????. ??? ??? ???? ??? ??? ????. closure?? ?? ??? ?? ??; ? ??? ??? ?? ?? ???? ?? ???? ????. V8 ??? ?? ???, ?? ??, ??/?? ???? ?? ??? ?? ??? ??? ????? ?? ??? ?? ??? ????. ?? ?? ???? ??? ??? ??? ??? ???? ????? ?? ?? ???? ?? ???????.

Node.js?? HTTP ??? ???? ? ?? ???? ??? ????. 1. ?? ????? ????? ??? ??? ? ?? ????? ?? ?? ? https.get () ??? ?? ??? ??? ? ?? ????? ?? ??? ?????. 2.axios? ??? ???? ? ?? ??????. ??? ??? ??? ??? ??? ??? ???/???, ?? JSON ??, ???? ?? ?????. ??? ?? ??? ????? ?? ????. 3. ?? ??? ??? ??? ??? ???? ???? ??? ??? ???? ?????.

JavaScript ??? ??? ?? ?? ? ?? ???? ????. ?? ???? ???, ??, ??, ?, ???? ?? ? ??? ?????. ?? ????? ?? ?? ? ? ??? ????? ?? ??? ??? ????. ??, ?? ? ??? ?? ?? ??? ??? ??? ???? ??? ??? ???? ??? ?? ??? ????. ?? ? ????? ??? ???? ? ??? ? ??? TypeofNull? ??? ?????? ??? ? ????. ? ? ?? ??? ???? ?????? ????? ???? ??? ???? ? ??? ? ? ????.

?????, JavaScript ???! ?? ? JavaScript ??? ?? ?? ?????! ?? ?? ??? ??? ??? ? ????. Deno?? Oracle? ?? ??, ??? JavaScript ?? ??? ????, Google Chrome ???? ? ??? ??? ???? ?????. ?????! Deno Oracle? "JavaScript"??? ????? Oracle? ?? ??? ??? ??????. Node.js? Deno? ??? ? Ryan Dahl? ??? ?????? ???? ????? JavaScript? ??? ???? Oracle? ????? ???? ?????.

?? JavaScript ??? ??? ??? ?????? ?? ??? ?? ?? ??? ?? ???? ????. 1. ??? ???? ???? ?? ??? ?? ? ? ???? ??? ??? ?? ? ?? ????? ?????. 2. Angular? ?????? ??? ?? ???? ? ?? ?? ??? ??? ??? ???? ?????. 3. VUE? ???? ?? ??? ???? ?? ?? ??? ?????. ?? ?? ?? ??, ? ??, ???? ???? ? SSR? ???? ??? ??? ??? ???? ? ??? ?????. ???, ??? ??? ??? ????? ????. ??? ??? ??? ??? ?? ????.

iife (?? invokedfunctionexpression)? ?? ??? ???? ?? ????? ??? ???? ?? ??? ????? ?? ??? ? ?????. ??? ?? ?? ??? ???? ? ?? ??? ??? ?? (function () {/code/}) ();. ?? ???? ??? ?????. 1. ?? ??? ??? ?? ???? ?? ??? ??? ?????. 2. ?? ??? ??? ???? ?? ?? ??? ????. 3. ?? ?? ??? ????? ?? ???? ???????? ?? ? ??. ???? ?? ???? ?? ??? ES6 ??? ??? ??? ?? ? ??? ????? ??? ? ???? ???????.

??? JavaScript?? ??? ??? ?????? ?? ???????. ?? ??, ?? ?? ? ??? ??? ?? ????? ????? ?????. 1. ?? ??? ??? ????? ???? ??. ()? ?? ??? ??? ?????. ?. ()? ?? ??? ?? ??? ??? ?? ? ? ????. 2. ?? ??? .catch ()? ???? ?? ??? ??? ?? ??? ??????, ??? ???? ???? ????? ??? ? ????. 3. Promise.all ()? ?? ????? (?? ?? ?? ? ??????? ??), Promise.Race () (? ?? ??? ?? ?) ? Promise.AllSettled () (?? ??? ???? ??)

Cacheapi? ?????? ?? ???? ??? ???? ???, ?? ??? ??? ?? ???? ? ??? ?? ? ???? ??? ??????. 1. ???? ????, ??? ??, ?? ?? ?? ???? ???? ??? ? ????. 2. ??? ?? ?? ??? ?? ? ? ????. 3. ?? ?? ?? ?? ?? ??? ??? ?? ?????. 4. ??? ???? ?? ?? ???? ?? ?? ?? ?? ?? ???? ?? ?? ??? ??? ? ????. 5. ?? ???? ??, ??? ??? ? ??? ??, ?? ??? ? ?? ???? ???? ???? ? ?? ?????. 6.?? ??? ?? ?? ?? ??, ???? ?? ? HTTP ?? ????? ?????? ???????.
