Leetcode Time Limit Exceeded Javascript Array Methods Cheat