Nth Magical Number Leetcode Javascript Questions