当前位置:网站首页>Daily question - leetcode824 - goat Latin - simulation
Daily question - leetcode824 - goat Latin - simulation
2022-04-21 22:09:00 【Li Fan, hurry up】
Just hard simulate the process The code is as follows :
class Solution {
public:
string toGoatLatin(string sentence) {
string ans;
for(int i = 0, p = 0; i < sentence.size(); i ++){
string word = "";
while(i < sentence.size() && sentence[i] != ' ')
word += sentence[i ++];
p ++;
char c = word[0];
if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U')
word += "ma";
else{
for(int j = 1; j < word.size(); j ++)
word[j - 1] = word[j];
word[word.size() - 1] = c;
word += "ma";
}
for(int k = 0; k < p; k ++)
word += 'a';
word += ' ';
ans += word;
}
ans.pop_back();
return ans;
}
};
版权声明
本文为[Li Fan, hurry up]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204212208082494.html
边栏推荐
- ROS robot from starting point to end point (IV) reproduction of blue bridge cloud practice
- Architecture document of outsourcing student management system
- 【最佳实践】巡检项:云服务器(CVM)实例本地盘类型检查
- 记录 splite3 库的一个坑(表名和字段定义不能用占位符?)
- Huayun actively responded to the anti epidemic call of Hefei high tech Zone: practicing social responsibility and contributing to the strength of science and technology enterprises
- ROS -- error in compiling PCL related programs: could not find a package configuration file provided by "PCL"“
- Software testing process and testing model
- 智慧化工园区解决方案
- LU分解、LDLT分解和Cholesky分解_zjuzly的博客-CSDN博客_ldlt
- [ES6] module import and export
猜你喜欢

Attack and defense world MFW

IDEA通过Jedis操作Linux上的Redis;Failed to connect to any host resolved for DNS name问题

How to connect ODBC database with PHP?

what? Your company has not set the JVM initial and maximum heap memory size to the same value?

Oracle级联删除表(不受外键约束)

Push to origin/master was rejected:报错解决办法
![[basic problems of function implementation C language]](/img/73/a400b286819f37a353cc6229e483fe.jpg)
[basic problems of function implementation C language]

kotlin核心编程,Android开发面试解答之Handler

How does PHP add an array element to an array

Restcloud ETL out of the box - permanently free
随机推荐
[ES6] object extension
One plus two earphone products: charge for 10 minutes and listen to music for 20 hours
数据库设计与实现
Authing officially joined the W3C organization and will participate in the formulation of relevant international standards
ROS——编译PCL相关程序报错:Could not find a package configuration file provided by “PCL“
【最佳实践】巡检项:云服务器(CVM)实例本地盘类型检查
【ES6】let和const命令
Attack and defense world MFW
【VSCode】调试器debugger详细使用手册
Document de conception de l'architecture du système de gestion des étudiants externalisé
ROS robot from starting point to end point (IV) reproduction of blue bridge cloud practice
面试必刷算法TOP101之背包九讲篇 TOP13
How to realize the automatic message sending function of wechat with vbs
【JVM】10道不得不会的JVM面试题
因为疫情让服装行业彻底认识到了数字化转型的必要性。
Idea operates redis on Linux through jedis; Failed to connect to any host resolved for DNS name
[ES6] string extension
[ES6] let and const commands
Vscode 插件包下载并离线安装
LU decomposition, LDLT decomposition and Cholesky decomposition_ Zjuzly's blog - CSDN blog_ ldlt
