Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Sliding Window Coding

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Sliding Window Coding. 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.

You need to log in / sign up to run or submit.

Problem

Palantir Foundry pipelines may process an ordered stream of event types from an operational workflow. Given the event types in arrival order, find the length of the longest contiguous subsequence containing no repeated event type.

Implement longest_unique_event_window(events).

Formal Specification

  • Input: events, a list of strings representing event types in chronological order.
  • Output: An integer representing the maximum length of a contiguous subsequence in which every event type appears at most once.
  • Event order must be preserved, and the selected subsequence must be contiguous.

Constraints

  • 0 <= len(events) <= 10^5
  • Each event type is a non-empty string of at most 100 characters
  • Event types are compared using exact, case-sensitive equality
  • Return 0 when events is empty

Function Signature

def longest_unique_event_window(events):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output