mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-04 20:31:59 +08:00
Remove -> None
for Python functions
This commit is contained in:
@ -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()
|
||||
|
@ -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