How to find maximum sum of a subarray of size k – Sliding window swift
[Question]: Find maximum sum of a subarray of size k example [9,1,3,2,6,1,5,9], k: 4 = output: 21 (6+1+5+9)Solution: with sliding window we can achieve. first we take sum of first k elements further move elements by 1 window size & add the latest var & remove last var.
How to find maximum sum of a subarray of size k – Sliding window swift Read More »