345. Reverse Vowels of a String 【E】
来源:互联网 发布:犀牛o2o源码 编辑:程序博客网 时间:2024/05/18 00:36
Write a function that takes a string as input and reverse only the vowels of a string.
Example 1:
Given s = "hello", return "holle".
Example 2:
Given s = "leetcode", return "leotcede".
Subscribe to see which companies asked this question
这个也是很简单,不过要注意元音字母还包括大写字母。。。
class Solution(object): def reverseVowels(self, s): v = ['a','e','i','o','u','A','E','I','O','U'] vovs = [] s = list(s) for i in xrange(len(s)): if s[i] in v: vovs += s[i], s[i] = None #vovs.reverse() #print vovs,s for i in xrange(len(s)): if s[i] == None: s[i] = vovs.pop() #print s return ''.join(s)
0 0
- 345. Reverse Vowels of a String 【E】
- String:345. Reverse Vowels of a String
- LeetCode 345. Reverse Vowels of a String
- 345. Reverse Vowels of a String
- leetcode-345. Reverse Vowels of a String
- 345. Reverse Vowels of a String
- #leetcode#345. Reverse Vowels of a String
- [leetcode] 345. Reverse Vowels of a String
- 345. Reverse Vowels of a String
- Leetcode:345. Reverse Vowels of a String
- LeetCode *** 345. Reverse Vowels of a String
- 345. Reverse Vowels of a String
- 345. Reverse Vowels of a String
- 345. Reverse Vowels of a String
- 345. Reverse Vowels of a String
- LeetCode.345. Reverse Vowels of a String
- 345. Reverse Vowels of a String
- LeetCode 345. Reverse Vowels of a String
- 字符串反转引发的char str[]="abc"和char *str="abc"思考
- $(document).ready()
- OpenCv学习笔记---OpenCv中支持向量机模块SVM------源代码分析
- 隐形变量赋值,隐藏参数,隐藏传参
- 2016sdau课程练习专题二 1020
- 345. Reverse Vowels of a String 【E】
- mysql一些实用的语句
- DayDayUP_Linux运维学习_oracle11g安装教程
- ios UITableView实现单击提示,滑动删除,多选行等操作
- ACM2-1003
- PHP是什么
- 测试总结
- HttpClient + Jsoup 网页数据抓取
- 暴搜 bnu51645 ACM Battle