Skip to main content
Back to problems
Leetcode
Easy
Arrays
Math
Simulation
Find If Digit Game Can Be Won

Determine whether the first player can win a digit-sum game by comparing the total value of one-digit and two-digit numbers.

Acceptance 0%
Problem Statement

Find If Digit Game Can Be Won

You are given an array of integers representing numbers written on cards. Two players play a simple game:

  • All one-digit numbers are assigned to the first player.
  • All two-digit numbers are assigned to the second player.
  • Each player's score is the sum of the numbers they receive.

Return true if the first player's score is strictly greater than the second player's score. Otherwise, return false.

You only need to determine whether the first player can win after splitting the cards by digit length as described above.

Input Format

  • An integer array nums.
  • Each value in nums is either a one-digit or two-digit positive integer.

Output Format

  • Return true if the sum of all one-digit numbers is greater than the sum of all two-digit numbers.
  • Otherwise, return false.

Constraints

  • 1 <= nums.length
  • Each element of nums is a positive integer with at most 2 digits.
  • Assume all numbers are valid for the game rules.

If exact official constraints are unknown, use the decision rule above as the governing behavior.

Examples
Sample cases returned by the problem API.

Example 1

Input

nums = [1, 2, 55, 9, 10]

Output

false

Explanation

One-digit sum = 1 + 2 + 9 = 12. Two-digit sum = 55 + 10 = 65. Since 12 is not greater than 65, the first player does not win.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.