File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 1- import './树/Bst'
1+ // import './树/Bst'
2+
3+ import './链表/main'
24
Original file line number Diff line number Diff line change 1+ // 若链表中的某个节点,既不是链表头节点,也不是链表尾节点,则称其为该链表的「中间节点」。
2+
3+ // 假定已知链表的某一个中间节点,请实现一种算法,将该节点从链表中删除。
4+
5+ // 例如,传入节点 c(位于单向链表 a->b->c->d->e->f 中),将其删除后,剩余链表为 a->b->d->e->f
6+ /**
7+ * @param {ListNode } node
8+ * @return {void } Do not return anything, modify node in-place instead.
9+ */
10+ export var deleteNode = function ( node ) {
11+ node . val = node . next . val ;
12+ node . next = node . next . next ;
13+ } ;
Original file line number Diff line number Diff line change 1+ import { bianli } from "../utils/linkList" ;
2+ import { deleteNode } from "./deleteLinkLIstItem" ;
3+ import { ListNode } from "./myLinkList" ;
4+
5+ const a = new ListNode ( 4 )
6+ const b = new ListNode ( 5 )
7+ const c = new ListNode ( 1 )
8+ const d = new ListNode ( 9 )
9+
10+ a . next = b
11+ b . next = c
12+ c . next = d
13+
14+ bianli ( a )
15+ deleteNode ( b )
16+ bianli ( a )
17+
18+ // 节点 5 (位于单向链表 4->5->1->9 中)
19+
You can’t perform that action at this time.
0 commit comments