Find First Repeating Element Leetcode Problems Javascript Array