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.
when u use listOfNumbers.remove(i); it removes and replace with next indexed number. So u need to check it again but u dont.
When u check it from end to start u needn't to check again cause of all from the end always checked.
Lists work not as arrays and have not fixed length.
This is how I got acquainted with getOrDefault().
Thanks)
So the for loop starts at the highest index in the List (size-1) and as long as the index is bigger than -1 (until it reaches 0, since that's still a valid index) it will perform the if statement, and remove any even number in the List without skipping anything. The problem with the initial code was that when you reach an even number while incrementing a for loop, it removed that number and caused all the subsequent numbers to shift their index down one place. This caused the bug of skipping over some even numbers. So you could either make sure you decrement i when you remove an even number if you use a normal increasing for loop, or you could start at the end and make your way down, since removing an even number won't affect the index of the previous terms. I hope this helps! :)
Seems like 1000+ java warriors didn't have an issue with this.
thats' because there are NO example tests provided. And that's effectively an issue.
I saw the problem like this with another kata a couple days ago. https://www.codewars.com/kata/do-i-get-a-bonus It also contains a Unicode char in tests.
Perhaps it needs to complain to developers of codewars?
My solution passed final test but preliminary tests was failed with exception about assertion error.
It is a dirty hack because objects are not really equal and nobody can use it this way because of possible bugs that very hard to find.
Please elaborate?
Tests throws assertion error.
These days I have this problem in java and I can't do any kata ...
SAME
Same for me :(
Approved - apologies for the 8 month delay :D
It takes me 5 minutes to solve. There is so complex description that solution must be very simple. First try and kata has solved.
Loading more items...