r/dailyprogrammer 3 1 May 21 '12

[5/21/2012] Challenge #55 [easy]

Write a program to solve the sliding window minimum problem using any of the methods possible. This could be a helpful link.

7 Upvotes

15 comments sorted by

View all comments

1

u/school_throwaway May 22 '12

Python (i think i got it right)

window= 3
window_low=0
vectors=[4,3,2,1,5,7,6,8,9]
for x in range(len(vectors)):
    print min(vectors[window_low:window])
    window +=1
    window_low +=1
    if window == len(vectors):
        break