Problem

For each distinct value, compute lastIndex - firstIndex; return the largest such span.

Examples

  • widestSpan([2, 1, 2, 3, 1]) -> 4
  • widestSpan([5, 5, 5]) -> 0
  • widestSpan([1, 3, 1, 3, 3]) -> 4
Compile and test (Ctrl+Enter)