Answer the question
In order to leave comments, you need to log in
Find the maximum distance between two equal numbers?
There is an array with numbers from 1 to 100000. It is necessary to find the maximum distance (the difference between the minimum element index and the maximum element index) for equal numbers.
For example, for [1, 3, 1, 4, 5, 4, 1] the distance would be 6.
Answer the question
In order to leave comments, you need to log in
We start the search from two sides of the array to meet each other.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question