Skip to content

Commit

Permalink
Update 01.Linked-List-Basic.md
Browse files Browse the repository at this point in the history
  • Loading branch information
itcharge committed Oct 18, 2023
1 parent 83f1519 commit bb9e5ea
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def create(self, data):
**「求线性链表长度」** 的代码如下:

```python
# 获取链表长度
# 获取线性链表长度
def length(self):
count = 0
cur = self.head
Expand All @@ -126,7 +126,7 @@ def length(self):
**「在链表中查找值为 $val$ 的元素」** 的代码如下:

```python
# 查找元素
# 查找元素:在链表中查找值为 val 的元素
def find(self, val):
cur = self.head
while cur:
Expand Down Expand Up @@ -242,7 +242,7 @@ def insertInside(self, index, val):
**「将链表中第 $i$ 个元素值改为 $val$」** 的代码如下:

```python
# 改变元素
# 改变元素:将链表中第 i 个元素值改为 val
def change(self, index, val):
count = 0
cur = self.head
Expand Down Expand Up @@ -301,7 +301,7 @@ def removeFront(self):
```python
# 链表尾部删除元素
def removeRear(self):
if not self.head.next:
if not self.head or not self.head.next:
return 'Error'

cur = self.head
Expand Down

0 comments on commit bb9e5ea

Please sign in to comment.