Skip to content

Commit fc39971

Browse files
committed
chore: update
1 parent cfc1f74 commit fc39971

File tree

122 files changed

+609
-890
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+609
-890
lines changed

code/algorithm/debounce.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/**
22
* 防抖
3-
* @param func
4-
* @param time
53
*/
64
function debounce(func, time) {
75
let timeout

code/algorithm/deepClone.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1+
/**
2+
* 判断数据类型
3+
*/
4+
function checkType(target) {
5+
// typeof -instanceof -toString.call() -Array.isArray()
6+
return Object.prototype.toString.call(target).slice(8, -1)
7+
}
18
/**
29
* 基于Json序列化的深拷贝【不能处理函数】
3-
* @param target
410
*/
5-
function DeepCloneByJSON(target) {
11+
export function DeepCloneByJSON(target) {
612
return JSON.parse(JSON.stringify(target))
713
}
814

915
/**
1016
* 基于递归思想的深拷贝
1117
*/
12-
function DeepClone(target) {
18+
export function DeepClone(target) {
1319
let result
1420
const targetType = checkType(target)
1521
if (targetType === 'object') {
@@ -29,16 +35,3 @@ function DeepClone(target) {
2935
}
3036
return result
3137
}
32-
33-
/**
34-
* 判断数据类型
35-
* @param target
36-
*/
37-
function checkType(target) {
38-
// typeof -instanceof -toString.call() -Array.isArray()
39-
return Object.prototype.toString.call(target).slice(8, -1)
40-
}
41-
42-
// 深拷贝
43-
console.log(DeepCloneByJSON)
44-
console.log(DeepClone)

code/algorithm/interview-101/binarySearch.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
/**
44
*
5-
* @param nums
6-
* @param target
75
*/
86
const search = function (nums, target) {
97
// 投机
@@ -15,8 +13,6 @@ const search = function (nums, target) {
1513

1614
/**
1715
* 二分查找
18-
* @param nums
19-
* @param target
2016
*/
2117
function binarySearch(nums, target) {
2218
let left = 0
@@ -42,8 +38,6 @@ function binarySearch(nums, target) {
4238

4339
/**
4440
* 左侧部分【第一个相同元素】
45-
* @param nums
46-
* @param target
4741
*/
4842
function leftBound(nums, target) {
4943
let left = 0
@@ -72,8 +66,6 @@ function leftBound(nums, target) {
7266

7367
/**
7468
* 右侧部分【最后一个相同元素】,[left,right) 情况
75-
* @param nums
76-
* @param target
7769
*/
7870
function rightBound(nums, target) {
7971
let left = 0
@@ -103,6 +95,6 @@ function rightBound(nums, target) {
10395

10496
const nums = [5, 7, 7, 8, 8, 8, 10]
10597
const target = 8
106-
console.log(search(nums, target))
107-
console.log(leftBound(nums, target))
108-
console.log(rightBound(nums, target))
98+
search(nums, target)
99+
leftBound(nums, target)
100+
rightBound(nums, target)

code/algorithm/interview-101/deleteDuplicates-1.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
/**
88
*
99
* @param head ListNode类
10-
* @return ListNode类
1110
*/
1211
function deleteDuplicatesOne(head) {
1312
console.log(head)
1413
}
1514

1615
// 测试用例
17-
console.log(deleteDuplicatesOne(1))
16+
deleteDuplicatesOne(1)

code/algorithm/interview-101/entryNodeOfLoop.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
* @param pHead
99
* @constructor
1010
*/
11-
function entryNodeOfLoop(pHead) {
11+
export function entryNodeOfLoop(pHead) {
1212
console.log(pHead)
1313
}
14-
15-
module.exports = {
16-
entryNodeOfLoop,
17-
}

code/algorithm/interview-101/fibonacci.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/**
22
* 斐波那契数列,递归调用
33
* 难度:入门
4-
* @param n
5-
* @returns {*}
64
*/
75
function fibonacciOne(n) {
86
return n < 2 ? n : fibonacciOne(n - 1) + fibonacciOne(n - 2)

code/algorithm/interview-101/findFirstCommonNode.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55

66
/**
77
* 【简单】 两个链表的第一个公共结点
8-
* @param pHead1
9-
* @param pHead2
10-
* @constructor
118
*/
129
function findFirstCommonNode(pHead1, pHead2) {
1310
console.log(pHead1, pHead2)

code/algorithm/interview-101/findKth.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ function quickSort(arr, low, high) {
3131

3232
/**
3333
* 获取节点
34-
* @param arr
35-
* @param low
36-
* @param high
3734
*/
3835
function getPivot(arr, low, high) {
3936
const pivot = arr[low]

code/algorithm/interview-101/findKthToTail.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
22
* 链表结点
33
*/
4-
// eslint-disable-next-line no-unused-vars,unused-imports/no-unused-vars
54
function ListNode(x) {
65
this.val = x
76
this.next = null

code/algorithm/interview-101/findNumbersWithSum.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/**
22
* 注意array是递增的
3-
* @param array
4-
* @param sum
53
*/
64
function FindNumbersWithSum(array, sum) {
75
let left = 0
@@ -41,4 +39,4 @@ function FindNumbersWithSum(array, sum) {
4139
return sumResult
4240
}
4341

44-
console.log(FindNumbersWithSum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], 21))
42+
FindNumbersWithSum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], 21)

0 commit comments

Comments
 (0)