当前位置:网站首页>824. Goat Latin
824. Goat Latin
2022-04-21 16:58:00 【anieoo】
Original link :824. Goat Latin
solution: Simulation question
class Solution {
public:
string toGoatLatin(string sentence) {
int n = sentence.length();
string res = ""; // Define the return value
for(int i = 0,k = 0;i < n;i++){
int j = i;
while(j < n && sentence[j] != ' ') j++;
k++; // Indexes +1
if(tolower(sentence[i]) == 'a' || tolower(sentence[i]) == 'e' || tolower(sentence[i]) == 'i' || tolower(sentence[i]) == 'o' || tolower(sentence[i]) == 'u'){
res += sentence.substr(i, j - i);
res += "ma";
for(int i = 0;i < k;i++)
res += "a";
if(j != n) res += " ";
}
else{
res += sentence.substr(i + 1,j - i - 1);
res += sentence[i];
res += "ma";
for(int i = 0;i < k;i++)
res += "a";
if(j != n) res += " ";
}
i = j;
}
return res;
}
};
版权声明
本文为[anieoo]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211651005778.html
边栏推荐
- 【微服务】微服务安全 - 如何保护您的微服务基础架构?
- Domain information query tool adfind
- 【观察】紫光云:同构混合云升级为分布式云,让云和智能无处不在
- Multi core and multi CPU programming -- task scheduling
- Shell case series 5 Oracle detects whether there are invalid objects
- Win10桥接网卡使得qemu虚拟机可以正常访问网络
- MySQL: 1103 error solution
- Sohu white society cross site vulnerability
- 2-4. Port binding
- 建议提供大纲 - 一键展开功能
猜你喜欢

Detailed explanation of spark SQL underlying execution process

Sqli labs 23-25a breakthrough experience and ideas

Summary of Wu Enda's course of machine learning (4)

Tips for idea cup filling -- Realizing mouse sliding guide bag

Vivado verifies the IP core generated by Vitis HLS

Summary of Wu Enda's course of machine learning (5)

Win10桥接网卡使得qemu虚拟机可以正常访问网络

疫情催化下,毫末智行这款产品为何能推动自动配送商业化加速?

Alexnet论文泛读:深度学习CV领域划时代论文具有里程碑意义NeurIPS2012

Excel表格中重要的数据如何隐藏不显示
随机推荐
Image Manipulation Detection by Multi-View Multi-Scale Supervision
2022 Beijing purchase strategy III (Policy)
R language uses cor function to calculate the correlation coefficient between multiple numerical data columns in dataframe and the rank correlation coefficient of Kendall's tau nonparametric
flutter dart ..addAll
k线图及单个k线图形态分析
R language uses the label function of hmisc package to add variable labels for specific variables (data columns) in dataframe, modify the data column name of dataframe to data description label, and a
C language - elaborate on functions and structures
L2-040 哲哲打游戏 (25 分) 模拟
Summary of Wu Enda's course of machine learning (4)
30. Overloading of construction method
微服务架构统一安全认证设计与实践
R language uses cor function to calculate the correlation coefficient between multiple numerical data columns in dataframe and Pearson product moment correlation coefficient
Domain information query tool adfind
吴恩达机器学习详细总结(三)
不同环境下控制@Schedule 开启
干货 | 实战演练基于加密接口测试测试用例设计
反弹base存在一个fd的情况
thrift简单应用
shell案例系列5-Oracle检测是否有失效对象
网易的XSS