Ad
  • Custom User Avatar

    For each iteration of the string using map, the callback executesindexOf which will iterate over the entire string again. This makes the solution O(n^2). If you know the strings won't ever be that long, then it's fine to optimize for readability. But, if you don't know, at least consider performance.

  • Custom User Avatar

    For each iteration of the string using map, the callback executesindexOf which will iterate over the entire string again. This makes the solution O(n^2). If you know the strings won't ever be that long, then it's fine to optimize for readability. But, if you don't know, at least consider performance.