We need to calculate the minimum cost required to go to climb all the way to the top of the stairs. Now, the criteria as to what counts as climbing is you can either climb one step or two steps at a time.
Code:
C++ (unoptimized, brute-force)
C++ (optimized for time)
Big O Analysis
The time complexity is O(N) because it iterates through the input nums list once. (For the unoptimized code, time complexity is O(N * k) where k = window length.)
The space complexity is O(N) as well, due to the result vector avgs we created of length N.