Top Coder In Leetcode Javascript Solution