Your question is Efficient Logic Coding Challenge. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
A Google Cloud Dataflow worker receives an ordered list of event labels. Given events and a set of required labels, return the shortest contiguous range of events that contains every required label at least once.
Return the range as [start, end], using inclusive zero-based indices. If no range contains all required labels, return [-1, -1]. If multiple ranges have the same minimum length, return the one with the smallest starting index.
events, a list of strings, and required, a list of distinct strings.[start, end] of integers, or [-1, -1] when no valid range exists.required at least once.required contains distinct labelsdef minimum_event_window(events, required):