Skip to content

Commit 59b4a6e

Browse files
authored
Create Solution.cpp
1 parent 8fad016 commit 59b4a6e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

solution/0412.Fizz Buzz/Solution.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public:
3+
vector<string> fizzBuzz(int n) {
4+
vector<string> Ret(n);
5+
6+
for(int i=1; i<=n; i++){
7+
8+
Ret[i-1] = (i%15 == 0) ? "FizzBuzz" : (i%3 == 0) ? "Fizz" : (i%5 == 0) ? "Buzz": to_string(i);
9+
10+
}
11+
12+
return Ret;
13+
}
14+
};

0 commit comments

Comments
 (0)