Ad
  • Custom User Avatar

    the clever votes are fine, but people voting "best practice" on this site either aren't looking at the other solutions or not much of an idea about computing overhead...

    this solution has n² compute time and memory; every position re-runs the array count, and the counting done by making new arrays and the call stack.
    whereas managing counts in a dictionary is n.

    I mean no ill to the author, it's nice to look at as a piece of code, a cool alternative, I'm fine with it being marked as clever, I really am.