Evaluate a Blackjack Hand
Updated
Problem 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.
More Goldman Sachs Onsite Interview questions
- Knight Probability in ChessboardONSITE INTERVIEW · Seen Nov 2026
- Best Average Student ScorePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Meeting RoomsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Minimum Meeting Rooms Without a Sweep LineONSITE INTERVIEW · Seen Oct 2026
- First Non-Repeating CharacterPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Root of the Largest TreePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Dungeon HealthONSITE INTERVIEW · Seen Sep 2026
- Insert, Delete, And Get Random In Constant TimeONSITE INTERVIEW · Seen Sep 2026
- Least Recently Used CacheONSITE INTERVIEW · Seen Sep 2026
- Staircase Search In A Sorted MatrixONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Latest Arrival Time for a ShuttleGoogle · ONSITE INTERVIEWGoogle interview questions
- Assign Partitions to the Least-Loaded ServersAmazon · ONSITE INTERVIEW
- Team-Preferred Stable MatchingBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
- Total Stops of an Elevator Serving a QueueExpedia · ONSITE INTERVIEWExpedia interview questions
- Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Climb Detection with Recoverable DipsStrava · PHONE SCREEN
- Final Pod Counts After LogsSalesforce · OASalesforce interview questions
- Text JustificationUber · PHONE SCREENUber interview questions
- Experiment Bucket Allocation and RebalancingPinterest · PHONE SCREENPinterest interview questions
- Find GPU Capacity and Drain a NodeTogether AI · PHONE SCREEN