Amazon interview question

Reverse a given linked list

Interview Answer

Anonymous

12 Feb 2021

As we all know that poker cards have four suites: Spades, Hearts, Clubs and Diamonds with figures from 1 to 13. Now you are given a set of poker cards, you can pick any one card as the first card. And except for the first card, you can only pick the card that has the same suit or figure with the previous one. Return the max number of cards you can. For example: [(H, 3), (H, 4), (S, 4), (D, 5), (D, 1)], it returns 3 as follows: (H,3)-->(H,4)-->(S,4)