Leetcode Problem On Array Methods In Typescript