Minimum Average Subarray | Algorithms Notes
Given an array A of n integers, design a linear time algorithm to find a subarray that has length at least 2 with minimum average.
Solution:
For any minimum average subarray, there exists either a length 2 subarray or a length 3 subarray with the same average starting at the same location. Hence, just need to check every consecutive average for all pairs and triples.
Read full article from Minimum Average Subarray | Algorithms Notes
No comments:
Post a Comment