Skip to content

Commit

Permalink
August 1 Daily
Browse files Browse the repository at this point in the history
  • Loading branch information
yufeige4 committed Aug 1, 2022
1 parent 22f21ef commit de0ba33
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Algorithms/Greedy/LC1374.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <bits/stdc++.h>

using namespace std;

// 1374. 生成每种字符都是奇数个的字符串

// 给你一个整数 n,请你返回一个含 n 个字符的字符串,其中每种字符在该字符串中都恰好出现 奇数次 。

// 返回的字符串必须只含小写英文字母。如果存在多个满足题目要求的字符串,则返回其中任意一个即可。

class Solution {
public:
string generateTheString(int n) {
if(n%2){
return string(n,'a');
}
return string(n-1,'a')+"b";
}
};

0 comments on commit de0ba33

Please sign in to comment.