mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 04:31:55 +08:00
Remove -> None for Python functions
This commit is contained in:
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user