Skip to content

Commit bac6c58

Browse files
committed
feat(cpp): add birthday cake candles
1 parent ba2b1c6 commit bac6c58

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

cpp/problems/birthdayCakeCandles.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <bits/stdc++.h>
2+
3+
using namepsace std;
4+
5+
int birthdayCakeCandles(vector<int> candles)
6+
{
7+
int max = 0;
8+
int count = 0;
9+
10+
for (int i = 0; i < candles.size(); i++)
11+
{
12+
if (candles[i] > max)
13+
{
14+
max = candles[i];
15+
count = 1;
16+
}
17+
else if (candles[i] == max)
18+
{
19+
count++;
20+
}
21+
}
22+
23+
return count;
24+
}

0 commit comments

Comments
 (0)