Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Iterate through the cards and store the location of the last occurrence of each number.
What data structure could you use to get the last occurrence of a number in O(1) or O(log n)?