Tiếp tục thread này thảo luận - Leetcode mỗi ngày (https://voz.vn/t/leetcode-moi-ngay.568742/latest) do quá nhiều trang, ae bớt spam lại.
Update: Pin thread cho đỡ trôi
Update: Pin thread cho đỡ trôi



chắc dạo này gia nhập đội xe ôm công nghệ hơi nhiềuvoz giờ người người leetcode, nhà nhà leetcode, chắc tương lai 90% vozer là bảo vệ

Mấy job e thích toàn đòi leetcode thôivoz giờ người người leetcode, nhà nhà leetcode, chắc tương lai 90% vozer là bảo vệ

class Solution {
public:
int maxCount(vector<int>& banned, int n, int maxSum) {
unordered_set<int> cnt(banned.begin(), banned.end());
int ans = 0;
int currentSum = 0;
for (int i = 1; i <= n; i++) {
if (currentSum + i <= maxSum && !cnt.count(i)) {
currentSum += i;
ans++;
}
if (currentSum > maxSum) break;
}
return ans;
}
};