1、问题描述

2、问题分析

将句子拆分成单词,然后放入vector中,对每一个单词做改变,最后连成句子返回。

3、代码

 string toGoatLatin(string S) {
vector<string> words;
for(string::iterator it = S.begin() ; it != S.end(); ++it ){
string::iterator it_i = it ;
while( it_i != S.end() && isalpha( *it_i) ){
++it_i ;
}
string word(it,it_i);
words.push_back( word );
if( it_i != S.end() ){
it = it_i;
}else{
it = it_i - ;
}
} string result ;
string a = "a";
set<string> vowels{"a","e","i","o","u","A","E","I","O","U"};
for( auto &s : words ){
if( vowels.find( s.substr(,) ) != vowels.end() ){
s += "ma";
}else{
s += s[];
s.erase( s.begin() );
s += "ma";
}
s += a;
a += "a";
result += s += " ";
} result.erase( result.end() - );
return result ; }

LeetCode 题解之Goat Latin的更多相关文章

  1. LeetCode算法题-Goat Latin Easy(Java实现)

    这是悦乐书的第322次更新,第344篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第192题(顺位题号是824).给出句子S,由空格分隔的单词组成.每个单词仅由小写和大写 ...

  2. 【LeetCode】824. Goat Latin 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...

  3. [LeetCode] Goat Latin 山羊拉丁文

    A sentence S is given, composed of words separated by spaces. Each word consists of lowercase and up ...

  4. LeetCode 824 Goat Latin 解题报告

    题目要求 A sentence S is given, composed of words separated by spaces. Each word consists of lowercase a ...

  5. [LeetCode&Python] Problem 824. Goat Latin

    A sentence S is given, composed of words separated by spaces. Each word consists of lowercase and up ...

  6. [LeetCode] 824. Goat Latin

    Description A sentence S is given, composed of words separated by spaces. Each word consists of lowe ...

  7. C#LeetCode刷题之#824-山羊拉丁文​​​​​​​(Goat Latin)

    问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3971 访问. 给定一个由空格分割单词的句子 S.每个单词只包含大 ...

  8. 824. Goat Latin - LeetCode

    Questioin 824. Goat Latin Solution 题目大意:根据要求翻译句子 思路:转换成单词数组,遍历数组,根据要求转换单词 Java实现: 用Java8的流实现,效率太低 pu ...

  9. [Swift]LeetCode824. 山羊拉丁文 | Goat Latin

    A sentence S is given, composed of words separated by spaces. Each word consists of lowercase and up ...

随机推荐

  1. Azure Redis 缓存使用注意事项与排查问题文档整理

    StackExchange.Redis 使用名为 synctimeout 的配置设置进行同步操作,该设置的默认值为 1000 毫秒. 如果同步调用未在规定时间内完成,StackExchange.Red ...

  2. 一口一口吃掉Hexo(三)

    如果你想得到更好的阅读效果,请访问我的个人网站 ,版权所有,未经许可不得转载! 相信通过前一节的学习,你已经在你的本地部署好了你的网站,那么接下来就让你的朋友们通过网络访问你的网站吧!通过这一节你将免 ...

  3. FineBI学习系列之FineBI的ETL处理(图文详解)

    不多说,直接上干货! 这是来自FineBI官网提供的帮助文档 http://help.finebi.com/http://help.finebi.com/doc-view-48.html 目录: 1. ...

  4. springboot-32-使用mvc测试

    Spring Boot可以和大部分流行的测试框架协同工作:通过Spring JUnit创建单元测试:生成测试数据初始化数据库用于测试:Spring Boot可以跟BDD(Behavier Driven ...

  5. spring boot 自动更新静态文件和后台代码 -- 热部署

    在spring boot使用的过程中, 发现我修改了静态文件, 前台刷新后, 没有任何变化, 必须重新启动, 才能看到, 这简直不能让人接受. 那有什么方法来解决这个问题呢. Baidu之后, 得到了 ...

  6. 命令行下更好显示 postgresql 的查询结果

    之前在用 mysql 的时候发现,当列数特别多的时候,在 linux 命令行下,显示不太友好, 然后可以通过将 sql 末尾的 “:” 改为 “\G” 来处理,详情看 命令行下更好显示 mysql 查 ...

  7. JBOSS Spring Web

    jndi: <datasources> <xa-datasource> <jndi-name>jdbc/sss-local</jndi-name> &l ...

  8. gitlab之gitlab-ci和gitlab-runner<二>

    1.使用 该版未接入k8s,下一篇会写接入k8s. 配置项目使用gitlab-ci和gitlab-runner,在项目的根目录中添加.gitlab-ci.yml文件,用于触发pipeline. .ho ...

  9. 传统项目转前端工程化——路由跳转时出现浏览器锁死和白屏【该死的同步ajax】

    [一开始我想到是该死的同步ajax,但我没验证,把他忽略了] 在探索前端工程化vue-cli做spa时,从搜索结果页跳转商品详情页时,因为详情页有很多ajax请求,并且都用的同步请求,就会导致请求时浏 ...

  10. WPF备忘录(4)打个勾画个叉娱乐下

    <Path Grid.Column="2" Data="M43,5 L20,40 20,40 0,20 6,15 18,26 37,7 43,5 z" F ...