This is a card problem but you do not need to know anything about card games.
Given a deck of cards of X suits and Y ranks (e.g., normal decks have 4 suits and 13 ranks),
How do you find the highest (if any) five straight flush (i.e., five cards of the same suit
with contiguous/consecutive numbers)?
** Examples: **
Given a card of suit "1" rank "0" --> we write it as S1R0
Example:
INPUT 2: S0R7, S2R0, S0R1, S2R1, S2R2, S2R3, S2R5, S2R4
SOLUTION 2 -->S2R1-S2R5
INPUT 1: S1R2, S1R0, S1R1, S0R1, S1R3, S0R7, S1R4
SOLUTION 1 --> S1R0-S1R4 would be a solutionThe card class can be something like:
final int MaxSuit = 4;
final int MaxRank = 13;
final int MatchStraightFlushCards = 5;
class Card {
int suit; // eg. 0-3.
int rank; // eg. 0-12
}
Please write the function:
List<Card> findHighestStraightFlush(List<Card> arr);