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.
"If you use an array to store the number of occurances …"
it sound to me like a histogram, and for that a hash map would be a better data structure.
Your code is correct. However, the test cases are slightly broken so your code won't work.
Just get rid of the first
if
statement and it should be fine.This comment is hidden because it contains spoiler information about the solution
Aggree with you. I'm not sure that O(n^2) is a best practice. It looks compact but not optimal.