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.
@angelplusultra
Distinct() keeps the first instance of an element and discards the rest.
The reason we reverse is because we want to keep the last item, not the first. A requirement from the kata description: "keeping the last ( rightmost ) occurrence of each element"
So we reverse it, remove the duplicates, then reverse it again to get it back to the original order.
Why are you reversing the array in the first place?
it returns only uniqie elements.
So if you have numbers 1,2,3,5,4,1,2,3 your solution would be 5,4,1,2,3.
Method Reverse makes this array look like 3,2,1,4,5,3,2,1. Then method Distinct removes duplicates (second and all further duplicates), so we have it like 3,2,1,4,5. And next reverse returns an answer 5,4,1,2,3
What is Distinct?
This one has me a little confused. How do we pass in the val parameter for this one?
Please use spoiler flag next time.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Hi,
You won't need a switch for checking a simple boolean since there are only two options.
You'd usually use the switch statement for something like an enum where there are more possible cases.
This is weird, when I display my answer(which is an array) in the console it is correct but when I try return the answer(which is an array) it runs my code multiple times which causes me to get the answer wrong. Why is it doing that? scratching my head
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I dont understand how this works. If you don't mind, could you explain it? Im trying to learn different ways to solve problems. Thanks.
This was the hardest kata I've done so far lol. I enjoyed all 6 hours of trying to figure that out. Im feeling like a boss right now
I loved the challenge of this kata, it was definitely the hardest one I've done. What was up with the random tests section though, I feel it wasn't necessary.
Loading more items...