Skip to content

Commit 676d6bc

Browse files
add more leetcode solutions ⚡
1 parent 7242721 commit 676d6bc

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1493,4 +1493,6 @@
14931493

14941494
## Others <a name="others"></a>
14951495
- [Codeforces Solutions](./codeforces.com)
1496-
- Leetcode solutions synced using https://github.com/QasimWani/LeetHub
1496+
- Leetcode solutions synced using https://github.com/QasimWani/LeetHub
1497+
1498+
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
class Solution {
22
public:
33
vector<bool> kidsWithCandies(vector<int>& candies, int extraCandies) {
4-
auto most = *max_element(candies.begin(), candies.end());
5-
vector<bool> res(candies.size(), false);
6-
for (int i = 0; i < candies.size(); i++)
7-
if (candies[i] + extraCandies >= most)
8-
res[i] = true;
4+
auto max_candies = *max_element(candies.begin(), candies.end());
5+
vector<bool> res;
6+
for (auto candy: candies)
7+
res.push_back( (candy + extraCandies) >= max_candies);
98
return res;
109
}
1110
};

0 commit comments

Comments
 (0)