Skip to content

Commit b6e6cbc

Browse files
authored
Update DeleteDuplicatedNode.cpp
1 parent c82e5ee commit b6e6cbc

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

18_02_DeleteDuplicatedNode/DeleteDuplicatedNode.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ Distributed under the BSD license.
88
*******************************************************************/
99

1010
//==================================================================
11-
// 《剑指Offer——名企面试官精讲典型编程题》代码
12-
// 作者:何海涛
11+
// 《剑指Offer——名企面试官精讲典型编程题》代码
12+
// 作者:何海涛
1313
//==================================================================
1414

15-
// 面试题18(二):删除链表中重复的结点
16-
// 题目:在一个排序的链表中,如何删除重复的结点?例如,在图3.4(a)中重复
17-
// 结点被删除之后,链表如图3.4(b)所示。
15+
// 面试题18(二):删除链表中重复的结点
16+
// 题目:在一个排序的链表中,如何删除重复的结点?例如,在图3.4(a)中重复
17+
// 结点被删除之后,链表如图3.4(b)所示。
1818

1919
#include <cstdio>
2020
#include "../Utilities/list.h"
@@ -47,7 +47,6 @@ void DeleteDuplication(ListNode** pHead)
4747
pNext = pToBeDel->m_pNext;
4848

4949
delete pToBeDel;
50-
pToBeDel = nullptr;
5150

5251
pToBeDel = pNext;
5352
}
@@ -61,7 +60,7 @@ void DeleteDuplication(ListNode** pHead)
6160
}
6261
}
6362

64-
// ====================测试代码====================
63+
// ====================测试代码====================
6564
void Test(char* testName, ListNode** pHead, int* expectedValues, int expectedLength)
6665
{
6766
if(testName != nullptr)
@@ -86,7 +85,7 @@ void Test(char* testName, ListNode** pHead, int* expectedValues, int expectedLen
8685
printf("FAILED.\n");
8786
}
8887

89-
// 某些结点是重复的
88+
// 某些结点是重复的
9089
void Test1()
9190
{
9291
ListNode* pNode1 = CreateListNode(1);
@@ -112,7 +111,7 @@ void Test1()
112111
DestroyList(pHead);
113112
}
114113

115-
// 没有重复的结点
114+
// 没有重复的结点
116115
void Test2()
117116
{
118117
ListNode* pNode1 = CreateListNode(1);
@@ -138,7 +137,7 @@ void Test2()
138137
DestroyList(pHead);
139138
}
140139

141-
// 除了一个结点之外其他所有结点的值都相同
140+
// 除了一个结点之外其他所有结点的值都相同
142141
void Test3()
143142
{
144143
ListNode* pNode1 = CreateListNode(1);
@@ -164,7 +163,7 @@ void Test3()
164163
DestroyList(pHead);
165164
}
166165

167-
// 所有结点的值都相同
166+
// 所有结点的值都相同
168167
void Test4()
169168
{
170169
ListNode* pNode1 = CreateListNode(1);
@@ -189,7 +188,7 @@ void Test4()
189188
DestroyList(pHead);
190189
}
191190

192-
// 所有结点都成对出现
191+
// 所有结点都成对出现
193192
void Test5()
194193
{
195194
ListNode* pNode1 = CreateListNode(1);
@@ -216,7 +215,7 @@ void Test5()
216215
DestroyList(pHead);
217216
}
218217

219-
// 除了两个结点之外其他结点都成对出现
218+
// 除了两个结点之外其他结点都成对出现
220219
void Test6()
221220
{
222221
ListNode* pNode1 = CreateListNode(1);
@@ -244,7 +243,7 @@ void Test6()
244243
DestroyList(pHead);
245244
}
246245

247-
// 链表中只有两个不重复的结点
246+
// 链表中只有两个不重复的结点
248247
void Test7()
249248
{
250249
ListNode* pNode1 = CreateListNode(1);
@@ -260,7 +259,7 @@ void Test7()
260259
DestroyList(pHead);
261260
}
262261

263-
// 结点中只有一个结点
262+
// 结点中只有一个结点
264263
void Test8()
265264
{
266265
ListNode* pNode1 = CreateListNode(1);
@@ -275,7 +274,7 @@ void Test8()
275274
DestroyList(pHead);
276275
}
277276

278-
// 结点中只有两个重复的结点
277+
// 结点中只有两个重复的结点
279278
void Test9()
280279
{
281280
ListNode* pNode1 = CreateListNode(1);
@@ -290,7 +289,7 @@ void Test9()
290289
DestroyList(pHead);
291290
}
292291

293-
// 空链表
292+
// 空链表
294293
void Test10()
295294
{
296295
ListNode* pHead = nullptr;

0 commit comments

Comments
 (0)