Find the Longest Subarray with at Most Two Distinct Values
Company: Moody's
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
Overview: Find the length of the longest contiguous subarray containing no more than two distinct integer values. A correct solution maintains sliding-window invariants across repeated runs, negative values, empty input, and every boundary movement while meeting the linear-time goal.
Read the full Moody's Software Engineer interview experience this question came from