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.
Ruby is so beautiful <3!!
It seems to me that if the line is, for example, 'a' * 10000, then the complexity will be 10000 * 36 where 36 is the number of letters. I think this solution is not entirely suitable for lines with a lot of repeating characters.
yes but ruby probably created like 1 million objects under the hood which is why this is the slowest lol
Well I'll be damned...
seriously!? :)
Nope, this is not O(n^2). Just O(n) with a large coefficient (36, when corrected for digits).
Could you explain how this is O(n^2)?
This comment is hidden because it contains spoiler information about the solution
omg I tot it will only remove the first instance of the element it found! Didn't realise it will remove all element...
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
But its less readable. Nice trade to discuss hahaha
I feel so outmatched right about now
name is a String object.
String class has the [] instance method that let you
extract parts of the String object.
In this case name[0] returnes the first character of name
name[1..-1] will give back a new string without the first character
https://ruby-doc.org/core-2.7.2/String.html#method-i-5B-5D
Why name with an array and 0 ? name[0]
Loading more items...