Max Distance Between Same Elements Leetcode