Ma Leetcode Solution Javascript Substring