饿了么笔试 2.95
1. 1的数量 × 0的数量 + 1。数据类型用 long long int,过了95%。
2. 瞪眼法,找不同,写一串 if else。
3. 看了好多解法都是 tire。我太菜了直接用哈希模拟做的。
if (op == 1) {
hash[x]++;
} else if (op == 2) {
if (--hash[x] == 0) {
hash.erase(x);
}
} else {
long long int ret = -1;
for (const auto& [a, b] : hash) {
ret = max(ret, a ^ x);
}
}
复杂度O(n2),C++没超时。
2. 瞪眼法,找不同,写一串 if else。
3. 看了好多解法都是 tire。我太菜了直接用哈希模拟做的。
if (op == 1) {
hash[x]++;
} else if (op == 2) {
if (--hash[x] == 0) {
hash.erase(x);
}
} else {
long long int ret = -1;
for (const auto& [a, b] : hash) {
ret = max(ret, a ^ x);
}
}
复杂度O(n2),C++没超时。
全部评论
瞪眼法太贴切了哈哈哈哈哈,我写完那一串 if-else 给我自己都看笑了
请教一下第三题你这么写为什么是O(n2)?
太牛了,我做完前两道就直接提交了😂
相关推荐
点赞 评论 收藏
分享
点赞 评论 收藏
分享
10-19 18:20
福建师范大学 Java
下午吃泡馍:数字马力的薪资一般哇,5年经验的java/测试就给人一万出头,而且刚入职第三天就让人出差,而且是出半年
帮你内推|数字马力 校招 点赞 评论 收藏
分享
