Bean
Bean
为什么不能当Generator 函数使用
> > 例如:给定 nums1 = [1, 2, 2, 1],nums2 = [2, 2],返回 [2, 2]。 > > ```js > var nums1 = [1, 2, 2, 1], nums2 = [2, 2, 3,...
### 1 递归甩锅 ```js function reverse_digui(head) { if(!head) return null if(!head.next) return head const new_head = reverse_digui(head.next) // 先让 head.next 进行反转 head.next.next = head // 反转完成后, head.next 是新链表的尾节点, 再连接上 head ...
```js class LRUCahce { constructor(capacity) { this.cahce = new Map() this.capacity = capacity } get(key) { if (this.cache.has(key)) { const temp = this.cache.get(key) this.cache.delete(key) this.cache.set(key, temp) return temp } return...
```js let num2 = [1, 2, 3, 4, 5] let num1 = [2, 7, 8, 10] let len1 = num1.length - 1 let len2 = num2.length - 1 let len...
```js const getIntersectionNode = (head1, head2) => { const h1 = head1 const h2 = head2 while (h1 || h2) { if(h1.data === h2.data) return h1 h1 = h1 ===...
```js const nums = [-1, 0, 1, 2, -1, -4] const threeSum = (nums) => { const res = [] nums = nums.sort((a, b) => a - b) for (let...
```js function merge_link1(head1, head2) { if (!head1) return head2 if (!head2) return head1 let merge_head = null let merge_tail = null let min_data = null let curr1 = head1 let...
```js var intersection = function (nums1, nums2) { const map = {}, ans = [] nums1.forEach((element) => { if (!map[element]) map[element] = 1 }) nums2.forEach((element) => { if (map[element]) {...
```js // 正整数数组,可以使用 {} 来存储数据 var twoSum = function(nums, target) { let map = {} for(let i = 0; i< nums.length; i++) { let k = target-nums[i] if(map[k]) { return...