3232. Find if Digit Game Can Be Won Easy
1/**
2 * [3232] Find if Digit Game Can Be Won
3 *
4 * You are given an array of positive integers nums.
5 * Alice and Bob are playing a game. In the game, Alice can choose either all single-digit numbers or all double-digit numbers from nums, and the rest of the numbers are given to Bob. Alice wins if the sum of her numbers is strictly greater than the sum of Bob's numbers.
6 * Return true if Alice can win this game, otherwise, return false.
7 *
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">nums = [1,2,3,4,10]</span>
11 * Output: <span class="example-io">false</span>
12 * Explanation:
13 * Alice cannot win by choosing either single-digit or double-digit numbers.
14 * </div>
15 * <strong class="example">Example 2:
16 * <div class="example-block">
17 * Input: <span class="example-io">nums = [1,2,3,4,5,14]</span>
18 * Output: <span class="example-io">true</span>
19 * Explanation:
20 * Alice can win by choosing single-digit numbers which have a sum equal to 15.
21 * </div>
22 * <strong class="example">Example 3:
23 * <div class="example-block">
24 * Input: <span class="example-io">nums = [5,5,5,25]</span>
25 * Output: <span class="example-io">true</span>
26 * Explanation:
27 * Alice can win by choosing double-digit numbers which have a sum equal to 25.
28 * </div>
29 *
30 * Constraints:
31 *
32 * 1 <= nums.length <= 100
33 * 1 <= nums[i] <= 99
34 *
35 */
36pub struct Solution {}
37
38// problem: https://leetcode.com/problems/find-if-digit-game-can-be-won/
39// discuss: https://leetcode.com/problems/find-if-digit-game-can-be-won/discuss/?currentPage=1&orderBy=most_votes&query=
40
41// submission codes start here
42
43impl Solution {
44 pub fn can_alice_win(nums: Vec<i32>) -> bool {
45 false
46 }
47}
48
49// submission codes end
50
51#[cfg(test)]
52mod tests {
53 use super::*;
54
55 #[test]
56 fn test_3232() {
57 }
58}
59
Back
© 2025 bowen.ge All Rights Reserved.