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.
There are 6 code variations, all of them with removed lines
why didn't you remove the last two lines?
This comment is hidden because it contains spoiler information about the solution
this one saves one characters over mine xd
This comment is hidden because it contains spoiler information about the solution
Single exit strategy is a controversial discussed dogma. For instance the Object.equals() method uses multiple return statements. Just have a look at the source code. Perhaps you shall advise Oracle that you think they're using bad pracice and improve the Java code base with a better solution. Your approach may be good for these concrete kata, but it is indeed not a general valid way, to solve all problems of that type, as you can see.
Hence, my question was not about linking connections to anything, but wanting to know, how you would solve problems of that kind in general, if something like IntStream was not accessible. Since clairvoyance does not exist, nobody can elaborate how your solution would look like. This is just a red herring argument. I would be grateful, if you could take two minutes to show a good way that works even for cases when Streams don't work, with a single exit point. And of course, without a break in the loop, because it violates your choosen strategy.
If it was a replay to my comment can elaborate on your thought. I'm not sure that I've understood correctly what you are trying to convey.
What is the connection between import statements and best coding practices?
This comment is hidden because it contains spoiler information about the solution
Apart from the weird formatting multiple return statement is not a best practice.
sometimes I am so stupid it is astounding. I make things so much harder than it needs to be
To enhance fastness, it would be better to convert the String to StringBuilder, do the replaces like we did with String, and then convert the SB back to String. But it would still remain in O(n), thus it may not be worth the effort, but is nice to know.
Both solutions are in the same complexity class O(n). So it's not really a win to use a for loop, instead of just replacing several times. Your code has also a bad readability, and is therefore less maintainable in production.
Our method will not be slow like you say, only somewhat slower than yours --> See big O notation: https://en.wikipedia.org/wiki/Big_O_notation
Yes, your solution is shorter. But I think that we (developers) should write faster code. Imagine that your method will execute 1_000_000 times in production every 1 minute. It will be slow.
Also I think that this kata we can't solve with regex, because we have several replace templates.
Sorry for bad English.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Loading more items...