feat: 算法

add-license-1
xuwu 2021-04-13 21:48:01 +08:00
parent d2d50bc9ab
commit 59e33b8ecd
4 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1 @@
前端到底如何搞算法?

View File

@ -0,0 +1,27 @@
// 递归版
var reverseList = function(head) {
const dummy = new ListNode()
return reverse(head, dummy).next
};
function reverse (head, dummy) {
if (!head) return dummy
const tmp = head.next
head.next = dummy.next
dummy.next = head
head = tmp
return reverse(head, dummy)
}
// 迭代版
var reverseList = function(head) {
const dummy = new ListNode()
while (head) {
const tmp = head.next
head.next = dummy.next
dummy.next = head
head = tmp
}
return dummy.next
};

View File

@ -18,6 +18,7 @@
},
"homepage": "https://github.com/KieSun/fucking-frontend#readme",
"dependencies": {
"axios": "^0.21.1"
"axios": "^0.21.1",
"gitment": "^0.0.3"
}
}

View File

@ -13,3 +13,15 @@ follow-redirects@^1.10.0:
version "1.13.3"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.3.tgz#e5598ad50174c1bc4e872301e82ac2cd97f90267"
integrity sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA==
gitment@^0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/gitment/-/gitment-0.0.3.tgz#dbccbad7480b1345b656913bd70eff792a7b38b8"
integrity sha1-28y610gLE0W2VpE71w7/eSp7OLg=
dependencies:
mobx "^3.1.7"
mobx@^3.1.7:
version "3.6.2"
resolved "https://registry.yarnpkg.com/mobx/-/mobx-3.6.2.tgz#fb9f5ff5090539a1ad54e75dc4c098b602693320"
integrity sha512-Dq3boJFLpZEvuh5a/MbHLUIyN9XobKWIb0dBfkNOJffNkE3vtuY0C9kSDVpfH8BB0BPkVw8g22qCv7d05LEhKg==