11. Max Sum Subarray of size K
Last updated
Last updated
The problem can be found at the following link: Question Link
Easy approach, I use a sliding window approach. I maintain a running sum of the current window and slide the window by subtracting the element that goes out of the window and adding the new element. I update the maximum sum at each step.
Time Complexity: O(N), where N is the size of the array.
Auxiliary Space Complexity: O(1).
For discussions, questions, or doubts related to this solution, please visit our discussion section. We welcome your input and aim to foster a collaborative learning environment.
If you find this solution helpful, consider supporting us by giving a ⭐ star
to the getlost01/gfg-potd repository.