You are reading a single comment by @zooeyzooey and its replies. Click here to read the full conversation.
  • I think your problem is here:

    Object.keys(strNumMap).reduce((res, key) => {
      const index = str.indexOf(key);
      if (index > -1) {
        res[key] = index;
      }
      return res;
    }
    

    It's not handling strings with multiple of the same number correctly. E.g. 121 is getting mapped to 12 instead of 11.

About

Avatar for zooeyzooey @zooeyzooey started