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.
Just to say, I think this is a very efficient approach (if I say so myself), it seems to run faster then a lot of other solutions which have less code.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
It doesn't make any sense without any context. A string neither does nor does not end with no-one-knows-what. Returning a value is just hiding an error that someone (maybe you) will have to find one day when something weird happens because of it.
?
It's handled the same way as a
null
str
.Was just thinking it could return true or false even in a null case. Null ending parameter is (gracefully) handled so why not the str parameter too?
It is handled: an exception is thrown. How else would you handle that?
Null 'str' parameter is unhandled though :'(
Ah ok cheers, I get it now, appreciate your time all.
@dinglemouse: Thanks for your explanations and comments.
On the contrary, this Kata is very precisely worded:
Your task is to return the first longest string consisting of k consecutive strings taken in the array.
k
)One can't say it simpler:
In other words construct all strings constitued of k consecutive (following one another) strings of the array and return the first which has the longest length.
I think this description is very badly worded, perhaps its missing details or the tests are invalid, I'm doing it in Java 8 and find some of the test cases appear to contradict each other.
My question is what is missing from the description?
I need enough information to make it obvious why the below tests are correct, currently they appear invalid.
1- appears to say: find the first largest string, and then take that and one more string from the array (equaling two), and that matches the description
2- appears to match test 1
3- this appears to say take the second largest string 'wlwsasphmxx' first and then the largest 'owiaxujylentrklctozmymu'
4- even weirder, this appears to say take the third largest string and get the three consecutive strings from the array.. but no logic that would facilitate that is mentioned in the description.