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
The
ISSUE
label is for provable kata issues. Please use theQUESTION
label when asking a question and appropriate formatting when posting code. See https://docs.codewars.com/training/troubleshooting/#post-discourse.You changed the initial function signature, not a kata issue.