Remove -> None for Python functions

This commit is contained in:
krahets
2023-07-24 22:34:05 +08:00
parent ac0f405f9a
commit 90af225dae
31 changed files with 82 additions and 82 deletions

View File

@ -314,7 +314,7 @@
=== "Python"
```python title=""
def algorithm(n: int) -> None:
def algorithm(n: int):
a = 0 # O(1)
b = [0] * 10000 # O(1)
if n > 10:
@ -461,7 +461,7 @@
# do something
return 0
def loop(n: int) -> None:
def loop(n: int):
"""循环 O(1)"""
for _ in range(n):
function()

View File

@ -48,7 +48,7 @@ $$
```python title=""
# 在某运行平台下
def algorithm(n: int) -> None:
def algorithm(n: int):
a = 2 # 1 ns
a = a + 1 # 1 ns
a = a * 2 # 10 ns
@ -226,14 +226,14 @@ $$
```python title=""
# 算法 A 时间复杂度:常数阶
def algorithm_A(n: int) -> None:
def algorithm_A(n: int):
print(0)
# 算法 B 时间复杂度:线性阶
def algorithm_B(n: int) -> None:
def algorithm_B(n: int):
for _ in range(n):
print(0)
# 算法 C 时间复杂度:常数阶
def algorithm_C(n: int) -> None:
def algorithm_C(n: int):
for _ in range(1000000):
print(0)
```
@ -443,7 +443,7 @@ $$
=== "Python"
```python title=""
def algorithm(n: int) -> None:
def algorithm(n: int):
a = 1 # +1
a = a + 1 # +1
a = a * 2 # +1
@ -644,7 +644,7 @@ $$
=== "Python"
```python title=""
def algorithm(n: int) -> None:
def algorithm(n: int):
a = 1 # +0技巧 1
a = a + n # +0技巧 1
# +n技巧 2