Array Math 3232. Find if Digit Game Can Be Won ¶ Time: $O(n)$ Space: $O(1)$ C++JavaPython 1 2 3 4 5 6 7 8class Solution { public: bool canAliceWin(vector<int>& nums) { return accumulate(nums.begin(), nums.end(), 0, [](int acc, int num) { return acc + (num < 10 ? num : -num); }) != 0; } }; 1 2 3 4 5class Solution { public boolean canAliceWin(int[] nums) { return Arrays.stream(nums).map(num -> num < 10 ? num : -num).sum() != 0; } } 1 2 3class Solution: def canAliceWin(self, nums: list[int]) -> bool: return sum(num if num < 10 else -num for num in nums) != 0