← previousnext →
Problem
For each distinct value, compute lastIndex - firstIndex; return the largest such span.
Examples
widestSpan([2, 1, 2, 3, 1]) -> 4widestSpan([5, 5, 5]) -> 0widestSpan([1, 3, 1, 3, 3]) -> 4
For each distinct value, compute lastIndex - firstIndex; return the largest such span.
widestSpan([2, 1, 2, 3, 1]) -> 4widestSpan([5, 5, 5]) -> 0widestSpan([1, 3, 1, 3, 3]) -> 4