Answer the question
In order to leave comments, you need to log in
How to understand the condition of the problem?
Hello. The task:
Consider the leftmost and rightmost appearances of some value in an array. We'll say that the "span" is the number of elements between the two inclusive. A single value has a span of 1. Returns the largest span found in the given array. (Efficiency is not a priority.)
maxSpan([1, 2, 1, 1, 3]) → 4
maxSpan([1, 4, 2, 1, 4, 1, 4]) → 6
maxSpan([1, 4, 2, 1, 4, 4 , 4]) → 6
Answer the question
In order to leave comments, you need to log in
The number of elements between two extreme identical elements, including themselves.
In this problem, "span" is the extent, the length of the segment.
In the example, 1, 2, 1, 1, 3
this is the distance between the leftmost unit and the rightmost unit, including the ends. The position of the rightmost (3) minus the position of the leftmost (0) plus 1.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question