LeetCode 第 135 场双周赛. T1 - T3
原题链接
简单
作者:
autumn_0
,
2024-07-21 01:17:40
,
所有人可见
,
阅读 4
第一题
class Solution {
public:
string losingPlayer(int x, int y) {
int a = x;
int b = y / 4;
int ans = min(a, b);
if(ans % 2 == 1) return "Alice";
return "Bob";
}
};
第二题
class Solution {
public:
int minimumLength(string s) {
unordered_map<char, int> hash;
for(int i = 0; i < s.size(); i ++ )
hash[s[i]] ++ ;
int res = 0;
for(int i = 0; i < 26; i ++ )
if(hash[i + 'a'])
{
if(hash[i + 'a'] % 2) res += 1;
else res += 2;
}
return res;
}
};