Highest Pair

Published by Edward Clark in

You will be given a collection of five cards (representing a player's hand in poker). If your hand contains at least one pair, return the card number of the highest pair (trivial if there only exists a single pair). Else, return "".

Examples

highestPair(["A", "A", "Q", "Q", "6" ]) ➞ "A"

highestPair(["J", "6", "3", "10", "8"]) ➞ ""

highestPair(["K", "7", "3", "9", "3"]) ➞ "3"

highestPair(["K", "9", "10", "J", "Q"]) ➞ ""

highestPair(["3", "5", "5", "5", "5"]) ➞ "5"

Notes

Hands with three or more of the same card still count as containing a pair (see the last example).

Watch a quick demo on how Edabit works.