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.
This comment is hidden because it contains spoiler information about the solution
The
throws
signature is redundant since method is not re-throwing theBadCodeException
.This comment is hidden because it contains spoiler information about the solution
Futhermore, to avoid NPE, use the expected String as first argument:
"needle".equals(haystack[i])
Encryption part was easy, but then I realized that decryption is pretty much simmilar process, so I tried to contitue encrypting till I get the original string.
The problem is that for different inputs, the number of cycles to get original varies and I can't figure out the dependency. For some inputs every 4th iteration equals to input, for other 5, 11, 18, etc.
Could someone advice if I'm going in a right direction or should I just write the decrypt function doing the same in reverse order?
Nice one-liner, but the complexity is crazy because you call
IntStream.of(b)
a.length
times.