Skip to content

Commit d38ce29

Browse files
Alan TsengAlan Tseng
authored andcommitted
a
1 parent 4b63ab5 commit d38ce29

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

docs/DSA/Linked_List/0.linked_list.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,21 @@ void delete_node(Node* node, int n)
171171
刪除中間節點,我們可以使用 fast-slow pointer 的方法來找到中間節點。
172172
![alt text](assets/image-4.png)
173173
```c
174-
void delete_mid(Node* node)
174+
void delete_mid(Node* head)
175175
{
176+
if (!head || !head->next || !head->next->next) return;
176177
puts("delete mid");
177-
Node* slow = node->next; // 跳過 dummy head
178-
Node* fast = node->next; // 跳過 dummy head
179-
Node* pre = node;
180-
while (fast != NULL && fast->next != NULL)
178+
Node* slow = head->next; // 跳過 dummy head
179+
Node* fast = head->next; // 跳過 dummy head
180+
Node* pre = head;
181+
while (fast && fast->next)
181182
{
182183
pre = slow;
183184
slow = slow->next;
184185
fast = fast->next->next;
185186
}
186187
// 如果 slow 為 NULL,表示鏈表長度為 1 或 0,無需刪除
187-
if (slow!= NULL) {
188+
if (slow) {
188189
pre->next = slow->next;
189190
free(slow);
190191
}

docs/DSA/Tree/binary_tree.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
reverse

docs/assets/image-1.png

363 KB
Loading

docs/grow.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
- [國立清華大學科技管理學院-孫運璿科技講座演講](https://sunspeech.site.nthu.edu.tw/)

docs/health.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# health
2+
![alt text](assets/image-1.png)

0 commit comments

Comments
 (0)