Ctrl K

One Digit or Two

Easy
Number cards cards are laid out on a table. Two people play: the first player picks **one** of two piles, either all the one-digit cards or all the two-digit cards, and the second player gets every other card. The first player wins if the sum of their cards is strictly greater than the opponent's. Return True if the first player can pick a pile that wins, and False otherwise.
Example 1
cards=[7, 8, 12, 3] → True

The one-digit cards add up to 7 + 8 + 3 = 18 and the two-digit ones to 12. Taking the one-digit cards gives 18 against 12, a win.

Example 2
cards=[6, 4, 10] → False

Both piles add up to 10, so either choice ends in a tie, and a tie is not a win.

Example 3
cards=[45] → True

There are no one-digit cards. The first player takes the two-digit ones: 45 against 0.

Constraints
  • 1 ≤ len(cards) ≤ 100
  • 1 ≤ cards[i] ≤ 99
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsAdd One to a Digit Array EasyThe Lost Ticket EasyCorner Stamps on a Table EasyBest Product of Three EasyThe Biggest Triangle on the Board Easy
loading Python…
Input
cards=[7, 8, 12, 3]
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 118 tests on the server, hidden ones included.