Find shortest distance between two same elements in an array in O(1) S.C
Defining distance as distance between array indices. We could go for the O(n^2) elementwise comparison or O(n) hashmap storing indices. But is it possible to do this O(1) space and O(n) complexity?