Nth Magical Number Leetcode Problems Javascript Map