Leetcode Find The Index Of An Element In Period