当前位置:网站首页>【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';
}
};
边栏推荐
- 【web】理解 Cookie 和 Session 机制
- 考完PMP学什么?前方软考等着你~
- 790. 数的三次方根
- AI target segmentation capability for fast video cutout without green screen
- The principle and code implementation of intelligent follower robot in the actual combat of innovative projects
- Flask 报错:WARNING This is a development server. Do not use it in a production deployment
- OperatingSystemMXBean获取系统性能指标
- 因为WiFi原因navicat 无法连接数据库Mysql
- BioVendor人俱乐部细胞蛋白(CC16)Elisa试剂盒研究领域
- 记一个gorm初始化的坑
猜你喜欢
随机推荐
The state status is displayed incorrectly after the openGauss switch
网络层解析——IP协议、地址管理、路由选择
A good book for newcomers to the workplace
ros多客户端请求服务
Service discovery of kubernetes
KICAD 小封装拉线卡顿问题 解决方法
PHP live source code to achieve simple barrage effect related code
国标GB28181协议EasyGBS平台兼容老版本收流端口的功能实现
2022-08-01 mysql/stoonedb slow SQL-Q18 analysis
GTK RGB图像绘制
OperatingSystemMXBean获取系统性能指标
Outsourcing worked for three years, it was abolished...
OC中成员变量,实例变量和属性之间的区别和联系
TKU remembers a single-point QPS optimization (I wish ITEYE is finally back)
最大层内元素和
记一次gorm事务及调试解决mysql死锁
菜刀webshell特征分析
29. 删除链表中重复的节点
analog IC layout
第10章_索引优化与查询优化







![[Server data recovery] Data recovery case of server Raid5 array mdisk disk offline](/img/08/d693c7e2fff8343b55ff3c1f9317c6.jpg)

