Skip to content

Commit 190c9a3

Browse files
authored
feat: add javascript solution to lcci problem: No.02.03.Delete Middle Node (doocs#368)
* feat: add javascript solution to lcci problem: No.02.01.Remove Duplicate Node * feat: add javascript solution to lcci problem: No.02.02.Kth Node From End of List * feat: add javascript solution to lcci problem: No.02.03.Delete Middle Node
1 parent 53409d9 commit 190c9a3

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

lcci/02.03.Delete Middle Node/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,26 @@ class Solution {
6666
}
6767
```
6868

69+
### **JavaScript**
70+
71+
```js
72+
/**
73+
* Definition for singly-linked list.
74+
* function ListNode(val) {
75+
* this.val = val;
76+
* this.next = null;
77+
* }
78+
*/
79+
/**
80+
* @param {ListNode} node
81+
* @return {void} Do not return anything, modify node in-place instead.
82+
*/
83+
var deleteNode = function(node) {
84+
node.val = node.next.val
85+
node.next = node.next.next
86+
};
87+
```
88+
6989
### **...**
7090

7191
```

lcci/02.03.Delete Middle Node/README_EN.md

+20
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,26 @@ class Solution {
6060
}
6161
```
6262

63+
### **JavaScript**
64+
65+
```js
66+
/**
67+
* Definition for singly-linked list.
68+
* function ListNode(val) {
69+
* this.val = val;
70+
* this.next = null;
71+
* }
72+
*/
73+
/**
74+
* @param {ListNode} node
75+
* @return {void} Do not return anything, modify node in-place instead.
76+
*/
77+
var deleteNode = function(node) {
78+
node.val = node.next.val
79+
node.next = node.next.next
80+
};
81+
```
82+
6383
### **...**
6484

6585
```
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Definition for singly-linked list.
3+
* function ListNode(val) {
4+
* this.val = val;
5+
* this.next = null;
6+
* }
7+
*/
8+
/**
9+
* @param {ListNode} node
10+
* @return {void} Do not return anything, modify node in-place instead.
11+
*/
12+
var deleteNode = function(node) {
13+
node.val = node.next.val
14+
node.next = node.next.next
15+
};

0 commit comments

Comments
 (0)