diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/kids_max_num_candy.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/kids_max_num_candy.cpp')
-rw-r--r-- | other/kids_max_num_candy.cpp | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/other/kids_max_num_candy.cpp b/other/kids_max_num_candy.cpp deleted file mode 100644 index 8be7b4c..0000000 --- a/other/kids_max_num_candy.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// 1431. Kids With the Greatest Number of Candies -#include "leetcode.h" - -/* - * there are 'n' kids with candies. you are given an integer array 'candies', - * where each 'candies[i]' represents the number of candies the i'th kid has, - * and an integer 'extra' denoting the number of extra candies that you have. - * return a boolean array 'result' of length 'n' where 'result[i]' is 1 if, - * after giving the i'th kid all the 'extra', they will have the greatest number - * of candies among all the kids, or 0 otherwise. - */ - -class Solution { -public: - vector<bool> kidsWithCandies(vector<int> &candies, int extra) { - int m = 0; - vector<bool> ans; - for (int c : candies) - m = max(m, c); - for (int c : candies) { - if (c + extra >= m) - ans.push_back(1); - else - ans.push_back(0); - } - return ans; - } -}; - -int main() { - Solution obj; - vector<int> c1 = {2, 3, 5, 1, 3}, c2 = {4, 2, 1, 1, 2}, c3 = {12, 1, 12}; - for (auto i : obj.kidsWithCandies(c1, 3)) - cout << i << ' '; // expect: 1 1 1 0 1 - cout << endl; - for (auto i : obj.kidsWithCandies(c2, 1)) - cout << i << ' '; // expect: 1 0 0 0 0 - cout << endl; - for (auto i : obj.kidsWithCandies(c3, 10)) - cout << i << ' '; // expect: 1 0 1 - cout << endl; -} |