跳至主要内容

3232. Find if Digit Game Can Be Won

class Solution {
public:
bool canAliceWin(vector<int>& nums)
{
int a = 0;
int b = 0;
for (auto num : nums)
{
int carry = num / 10;
if (0 < carry && carry < 10) a += num;
else b += num;
}
return a == b ? false : true;
}
};
  • T: O(n)O(n)
  • S: O(1)O(1)