--- tags: data_structure_python --- # Largest Subarray Length K <img src="https://img.shields.io/badge/-easy-brightgreen"> - https://leetcode.com/discuss/interview-question/352459/ ![](https://i.imgur.com/6NyN0d4.png) ![](https://i.imgur.com/HVtr6w2.png) # Solution ```python= def largest_subarray_length_k(L, k): # Time complexity: O(nk). # Space complexity: O(). n = len(L) if n == k: return L else: nbSubarray = n - k largestSubarray = L[0:k] for i in range(1, nbSubarray): for a, b in zip(largestSubarray, L[i:i+k]): if b > a: largestSubarray = L[i:i+k] break elif b < a: break return largestSubarray print(largest_subarray_length_k([1, 4, 3, 2, 5], 4)) ```