We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ce82fed commit 09a4e89Copy full SHA for 09a4e89
array.py
@@ -10,10 +10,7 @@ def list_compare1(A,B):
10
Comment:
11
Still faster than: return all(A[n] == B[n] for n in range(0, len(A)))
12
"""
13
- for n in range(0,len(A)):
14
- if A[n] != B[n]:
15
- return False
16
- return True
+ return all(A[n] == B[n] for n in range(0, len(A)))
17
18
19
def list_compare2(A,B):
@@ -28,8 +25,7 @@ def list_compare2(A,B):
28
25
29
26
def fixed_sliding_window(arr, k):
30
27
result = [sum(arr[:k])]
31
- for i in range(0, len(arr)-k):
32
- result.append(result[i] + arr[i+k] - arr[i])
+ result.extend(result[i] + arr[i+k] - arr[i] for i in range(0, len(arr)-k))
33
return result
34
print(fixed_sliding_window(list(range(1,7)),3))
35
0 commit comments