Nikah Forever interview question

Maximum distance between two occurrences of same element in array