Problem · Array
Evaluate a Blackjack Hand
Learn this problemProblem statement
Given a blackjack hand in cards, return whether the cards can total exactly 21.
- Cards
2through10use their numeric values. J,Q, andKeach count as10.- Each
Amay independently count as1or11.
The hand may contain any positive number of cards.
Function
isBlackjack(cards: String[]) → booleanExamples
Example 1
cards = ["A","K"]return = trueThe Ace counts as 11, giving 21.
Example 2
cards = ["K","Q"]return = falseThe total is 20.
Constraints
1 <= cards.length <= 52- Every card is one of
A,2through10,J,Q, orK.