当前位置:网站首页>leetcode:1374. Generate an odd number of each character string
leetcode:1374. Generate an odd number of each character string
2022-08-06 03:11:00 【Soft-hearted and cool】
Difficulty: Easy
Given an integer n, please return a string of n characters, where each character occurs exactly an odd number of times in the string.
The returned string must contain only lowercase English letters.If there are multiple strings that meet the requirements of the question, any one of them can be returned.
Example 1:
Input: n = 4
Output: "pppz"
Explanation: "pppz" is a, since 'p' occurs 3 times and 'z' occurs 1 time.Of course, there are many other strings that also meet the title requirements, such as: "ohhh" and "love".Example 2:
Input: n = 2
Output: "xy"
Explanation: "xy" is a, because 'x' and 'y' each occur 1 time.Of course, there are many other strings that also meet the requirements of the title, such as: "ag" and "ur".Example 3:
Enter:n = 7Output:"holasss"Tip:
1 <= n <= 500
Solution:class Solution:def generateTheString(self, n: int) -> str:if n == 1:return 'a'else:if n%2 ==0:return 'a'*(n-1) + 'b'else:return 'a'*(n)
边栏推荐
- The first day of learning MySQL: MySQL overview (basic)
- 学习MySQL的第一天:MySQL概述(基础篇)
- js_array object is changed to be sorted (including parallel sorting)
- The third day of learning MySQL: functions (basic)
- 关于软件测试计划的面试题,你能答对几个?
- UIO & VFIO: DPDK实现PMD的基石
- 6 Usability Testing Methods That Improve Your Software
- 【无标题】
- 单人最高5万奖金!顶会论文复现赛正式启动,70+公开任务等你挑战
- 通行宝通过注册:年营收5.9亿拟募资5.6亿 腾讯云与上汽是股东
猜你喜欢
随机推荐
C Student management system Delete the specified student node (general situation)
KGAT推荐系统
实际工作开发中C语言工程的目录结构分析
KGAT recommendation system
栈和队列
预处理(C语言深度了解)
The third day of learning MySQL: functions (basic)
leetcode 17. Letter Combinations of Phone Numbers
C 学生管理系统 打印/修改指定位置信息
LeetCode Daily 2 Questions 01: Flip word prefixes (both 1200 questions)
WeChat applet multi-select - four choose two
DevEco Studio配置:自定义头部代码注释
物联网协议概述
走!VR技术带你沉浸式看展
sql server , 两个表,相同字段,相同数据量(5000万), 执行相同的查询,一个表执行的是索引扫描,扫描5000万,耗时2分钟, 另一个表执行的是索引查找,只查找10万,耗时1秒。为什么会有这么大的差别?
浦发银行长沙分行党委书记、行长王起,华融湘江银行行长蒋俊文一行莅临麒麟信安调研考察
【无标题】
3D激光SLAM:LIO-SAM整体介绍与安装编译
How to make a pictogram in PPT
二次开发入门须知








