r/dailyprogrammer • u/rya11111 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
4
u/crawphish May 22 '12
Can someone explain the Sliding Window Minimum... The link provided didnt really help me understand what it is...
2
u/prophile May 22 '12
One-liner in Python:
2
u/bh3 May 23 '12
Python:
Ideally I'd want to replace the list for the window with a circular one of length K to avoid any sort of array copying, etc and simply advance the head if the current head is too old and advance/decrease the tail as appropriate. But didn't want to bother writing a floor function for a circular array based list.
1
u/Yuushi May 22 '12
Python:
Not an efficient way, but hey, it's kind of pretty.
1
u/crawphish May 22 '12
1
u/school_throwaway May 22 '12
Python (i think i got it right)
1
u/SwimmingPastaDevil 0 0 May 22 '12
Python. Using crawphish's explanation.
1
u/MusicalWatermelon May 22 '12
Python:
1
u/[deleted] May 22 '12
Haskell:
1
u/gtklocker May 23 '12
Just started doing some Lua.
1
u/flakmonkey May 23 '12 edited May 23 '12
Python:
1
u/leftplusright May 27 '12
Python: