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.
Easily best practice.
This comment is hidden because it contains spoiler information about the solution
Great solution. In the LCM method, I would do the division before the multiplication to help avoid overflow. With two input values of length O(n), the intermediate value is length O(n^2) doing multiplication first and O(n) doing division first.
I like the use of the direction enum
How is this O(n/2) if you're still doing ~n comparisons? The loop runs n/2 times but you do 2 comparisons per loop. O(n) is still great though, better than sorting
Avoids memory usage and uses a cool property of the golden ratio. Love it.
More generally, solution is O(n*R) where n is the length of the sentence and R is the size of your alphabet (disregarding the call of toLowerCase() in every iteration of the loop) – but it can still be done in O(n).