This is the simplest sliding window / running minimum problem and introduces the concept of tracking state as you iterate.
Enable JavaScript for the full StreamPrep guide.