A
A
Alexander2016-03-11 23:33:59
Algorithms
Alexander, 2016-03-11 23:33:59

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

1 answer(s)
E
evgeniy_lm, 2016-03-12
@evgeniy_lm

We start the search from two sides of the array to meet each other.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question