Hi for my solution I’d like to understand if this is not good because I’m not doing the sliding window in-situ? Otherwise my time complexity is O(n) isn’t it?
def max_sub_array_of_size_k(k, arr):
n = len(arr)
arr_sum = []
for i in range(n):
arr_sum.append(sum(arr[i:i+k]))
return max(arr_sum)
def main():
out = max_sub_array_of_size_k(3,[2, 1, 5, 1, 3, 2])
print(out)
main()