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.
look at the tests
You need
chars()
to safely iterate UTF characters of astr
. Strings are always UTF-8 encoded, so accessing the bytes directly would be problematic. Thecollect()
at the end consumes theIterator
into aString
.For better functional composition, a more flexible signature would be:
This way you could pass any iterable into the function (including
str.chars()
), and chain the function lazily, without allocating a String for output.This comment is hidden because it contains spoiler information about the solution
I believe in you, WarriorZero
Ok. I get it. Generating green numbers is expensive - To do it in less than O(nlogn) would require a lot of effort (if it's even possible). However, given that n will always be <=3000, there might be a better way to do it.
I suggest to generate the first 10..20 elements or so with your code, and then examine it. You may notice a certain pattern... If so, try to make use of it somehow.
Cheers
After I could see @Blind4Basics's answer I was able to find and fix the problem. IMO it worths mentionning in the description, that the source array shouldn't be mutated.
I'm hitting the same issue. All random tests seem to expect empty result set. Can you please share what solved the issue for you?
This is an algorithm kata. So an efficient algorithm is required.
From the looks of it, it suggests nothing but that you're simply not capable enough for this kata.
My only suggestion is that you shouldn't be attempting this kata in the first place (because of the huge skill mismatch), and you should go try something else.
Thx!!
Programmers and Genice .
I write the code but it take alot of time as it +1 (add one) for each loop
How can I solve like this problem
Note I must +1 in one step to get the answer
Any suggestion >>>
plz remove this question
I get it
Translation approved
you need to clarify the "returns n th " in " Your task is to write a function green that returns n th green number, starting with 1 - green (1) == 1"
what is the thing to return exactly?
Eng is not my native language ,
And I work on improve it :)
Loading more items...