当前位置:网站首页>【LeetCode】1374. 生成每种字符都是奇数个的字符串
【LeetCode】1374. 生成每种字符都是奇数个的字符串
2022-08-02 02:40:00 【酥酥~】
题目
给你一个整数 n,请你返回一个含 n 个字符的字符串,其中每种字符在该字符串中都恰好出现 奇数次 。
返回的字符串必须只含小写英文字母。如果存在多个满足题目要求的字符串,则返回其中任意一个即可。
示例 1:
输入:n = 4
输出:“pppz”
解释:“pppz” 是一个满足题目要求的字符串,因为 ‘p’ 出现 3 次,且 ‘z’ 出现 1 次。当然,还有很多其他字符串也满足题目要求,比如:“ohhh” 和 “love”。
示例 2:
输入:n = 2
输出:“xy”
解释:“xy” 是一个满足题目要求的字符串,因为 ‘x’ 和 ‘y’ 各出现 1 次。当然,还有很多其他字符串也满足题目要求,比如:“ag” 和 “ur”。
示例 3:
输入:n = 7
输出:“holasss”
提示:
1 <= n <= 500
class Solution {
public:
string generateTheString(int n) {
if(n%2==1)
return string(n,'a');
return string(n-1,'a')+'b';
}
};
边栏推荐
- Moonbeam and Project integration of the Galaxy, bring brand-new user experience for the community
- JVM调优实战
- Nacos源码分析专题(二)-服务注册
- [ORB_SLAM2] SetPose, UpdatePoseMatrices
- Nanoprobes免疫测定丨FluoroNanogold试剂免疫染色方案
- 淘宝详情.
- 2022-08-01 Install mysql monitoring tool phhMyAdmin
- cocos中使用async await异步加载资源
- MySQL索引优化实战
- 很有意思的经历,很有意思的项目--文件夹对比工具
猜你喜欢

使用docker安装mysql

BioVendor Human Club Cellular Protein (CC16) Elisa Kit Research Fields

项目场景 with ERRTYPE = cudaError CUDA failure 999 unknown error

analog IC layout-Environmental noise

国标GB28181协议EasyGBS平台兼容老版本收流端口的功能实现

240...循迹

ros多客户端请求服务

工程师如何对待开源

【Unity入门计划】2D Game Kit:初步了解2D游戏组成

Nanoprobes纳米探针丨Nanogold偶联物的特点和应用
随机推荐
[ORB_SLAM2] SetPose, UpdatePoseMatrices
【ORB_SLAM2】void Frame::AssignFeaturesToGrid()
IMU预积分的简单理解
Pinduoduo leverages the consumer expo to promote the upgrading of domestic agricultural products brands and keep pace with international high-quality agricultural products
项目场景 with ERRTYPE = cudaError CUDA failure 999 unknown error
亲身经历过的面试题
The state status is displayed incorrectly after the openGauss switch
Nanoprobes免疫测定丨FluoroNanogold试剂免疫染色方案
feign调用不通问题,JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r
Remember a gorm transaction and debug to solve mysql deadlock
Flask之路由(app.route)详解
analog IC layout-Design for reliability
Safety (1)
数仓:数仓从ETL到ELT架构的转化以及俩者的区别
淘宝详情.
mysql 查看死锁
[Unity entry plan] 2D Game Kit: A preliminary understanding of the composition of 2D games
很有意思的经历,很有意思的项目--文件夹对比工具
analog IC layout-Environmental noise
TKU remembers a single-point QPS optimization (I wish ITEYE is finally back)