質問編集履歴
3
内容の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,15 +22,9 @@
|
|
22
22
|
|
23
23
|
def deleteNode(self, node):
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
25
|
# :type node: ListNode
|
30
26
|
|
31
27
|
# :rtype: void Do not return anything, modify node in-place instead.
|
32
|
-
|
33
|
-
|
34
28
|
|
35
29
|
pre = node
|
36
30
|
|
2
内容の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,9 +6,31 @@
|
|
6
6
|
|
7
7
|
```Python
|
8
8
|
|
9
|
+
# Definition for singly-linked list.
|
10
|
+
|
11
|
+
# class ListNode:
|
12
|
+
|
13
|
+
# def __init__(self, x):
|
14
|
+
|
15
|
+
# self.val = x
|
16
|
+
|
17
|
+
# self.next = None
|
18
|
+
|
19
|
+
|
20
|
+
|
9
21
|
class Solution:
|
10
22
|
|
11
23
|
def deleteNode(self, node):
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
# :type node: ListNode
|
30
|
+
|
31
|
+
# :rtype: void Do not return anything, modify node in-place instead.
|
32
|
+
|
33
|
+
|
12
34
|
|
13
35
|
pre = node
|
14
36
|
|
1
内容の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -47,3 +47,29 @@
|
|
47
47
|
これらは、どういうものなのでしょうか。
|
48
48
|
|
49
49
|
Leetcodeではみなさん当然のように書いているのですが理解が進まなくて質問しました。
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
------------
|
54
|
+
|
55
|
+
Leetcodeでの問題は以下の通りです。
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.
|
60
|
+
|
61
|
+
Given linked list -- head = [4,5,1,9], which looks like following:
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
4 → 5 → 1 → 9
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
Example 1:
|
70
|
+
|
71
|
+
Input: head = [4,5,1,9], node = 5
|
72
|
+
|
73
|
+
Output: [4,1,9]
|
74
|
+
|
75
|
+
Explanation: You are given the second node with value 5, the linked list should become 4 -> 1 -> 9 after calling your function.
|