Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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.