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.
Using streams for simple tasks like finding the maximum product of adjacent elements in an array is certainly a valid approach, and it can make your code look clean and concise. However, there are a few reasons why some developers might prefer using loops over streams for such tasks:
Readability and Maintainability: While streams can make code look concise, they might not always be as readable as traditional loops, especially for more complex operations. For someone who is not familiar with streams, understanding the code might be more challenging. In contrast, loops often have a more straightforward and intuitive syntax.
Performance Overhead: Streams can introduce some performance overhead compared to traditional loops. Streams have to perform additional operations such as creating an iterator, invoking the lambda function for each element, and handling the stream pipeline. For simple operations, like iterating through an array and performing a basic operation, the performance impact might be negligible. However, for performance-critical operations, loops could be more efficient.
Learning Curve: While streams provide a powerful and expressive way to process collections, they also introduce a learning curve. Developers who are not familiar with streams might need to spend some time learning the concepts and best practices. Traditional loops, on the other hand, are more widely understood and easier to pick up for beginners.
Debugging and Testing: Debugging and testing might be easier with traditional loops since you can easily add breakpoints, inspect variables, and step through the code. Streams, especially more complex ones, might make debugging more challenging.
Code Reviews and Team Collaboration: In a team setting, it's important to consider the familiarity of your team members with certain coding styles. Using more commonly understood constructs, like traditional loops, can lead to better collaboration and code reviews.
It's important to note that whether you choose to use streams or loops often depends on the context, the complexity of the operation, performance considerations, and the preferences and expertise of your development team. In many cases, both streams and loops have their place and can be used effectively.
EntityPlantt is right. As for the second question, it's impossible to answer without seeing the code
The first Woof! wasn't counted because the second sentence/letter has woof 27 times, thus making the test invalid. The task description says: in case when any of the woof-sentences has more than 26 woofs, you should return
just barking!
.Woof! Woof-woof-woof-woof-woof-woof-woof-woof-woof-woof-woof-woof-woof-woof-woof-woof-woof-woof-woof-woof-woof-woof-woof-woof-woof-woof-woof!
Why in this string first "Woof!" isn't considered as "a" in the test?
second. for some reason i get right answer in my ide, but here i don't get the same with the same code.
expected: "lknfjicf" but was: "squirrel"
but in my ide i get "lknfjicf"
omg, how stupid I am.
Guys, can someone explain why is this solution not best practice? I mean rather in general, not exactly this one, but loops are better, than streams or what? Streams looks so neat.