leetcode345
public class Solution {
public string ReverseVowels(string s) {
var str = s.ToList();
var Vowels = new List<char>();
for (int i = ; i < str.Count; i++)
{
var c = str[i];
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'
|| c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U')
{
Vowels.Add(c);
}
}
if (Vowels.Count > )
{
Vowels.Reverse();
int j = ;
for (int i = ; i < str.Count; i++)
{
var c = str[i];
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'
|| c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U')
{
str[i] = Vowels[j];
j++;
}
}
}
StringBuilder sb = new StringBuilder();
foreach (var c in str)
{
sb.Append(c);
}
return sb.ToString();
}
}
https://leetcode.com/problems/reverse-vowels-of-a-string/#/description
leetcode345的更多相关文章
- leetcode345——Reverse Vowels of a String(C++)
Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Giv ...
- [Swift]LeetCode345. 反转字符串中的元音字母 | Reverse Vowels of a String
Write a function that takes a string as input and reverse only the vowels of a string. Example 1: In ...
- LeetCode 345
Reverse Vowels of a String Write a function that takes a string as input and reverse only the vowels ...
随机推荐
- oracle在进行跨库访问时,采用dblink实现
首先了解下环境:在tnsnames.ora中配置两个数据库别名:test1/test1@11orcl1.tets2/tets2@12orlc2,在orcl1中创建database link来访问orc ...
- grandstack graphql 工具基本试用
grandstack 是一个方便graphql 应用开发的工具 使用docker-compose 运行 环境准备 官方的starter 比较好,已经是使用docker-compose 创建好了所有 ...
- spring答题
ioc 依赖注入:通过注入的方式实例化对象,不再直接new对象了,交给spring容器进行管理和维护 控制反转:实例化对象的控制权交给了spring容器,而不再是某个单独的类,控制权发生了变更 作用: ...
- win10下ASP.NET Core 2.0部署环境搭建(转)
此文用于记录在win10环境下,新建的Asp.net Core 2.0 Web应用项目如何运行在IIS上 一.运行环境 操作系统: Window10 家庭中文版 版本 10.0.15063 版本 15 ...
- Word中回车和网页换行替换
回车^p 换行^l 用编辑中的查找替换即可 查找^l,替换为^p (一)有建议说按Delete键一个一个将其删除,这是麻烦的,其实可用WORD的查找替换工具一次性替换成回车符.查找--点特殊字符--手 ...
- Grid中添加链接,打开选项卡页面
如何在grid中点击,添加一个选项卡并打开页面 function addeditnew(id, title) { var node ...
- bzoj 3674 可持久化并查集加强版——可持久化并查集
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3674 用主席树维护 fa[ ] 和 siz[ ] .改 fa[ ] 和改 siz[ ] 都 ...
- 使用scrapy框架爬取自己的博文(3)
既然如此,何不再抓一抓网页的文字内容呢? 谷歌浏览器有个审查元素的功能,就是按树的结构查看html的组织形式,如图: 这样已经比较明显了,博客的正文内容主要在div 的class = cnblogs_ ...
- 禁止HTML页面缓存
head标签里增加: <meta http-equiv="X-UA-Compatible" content="IE=8"> <meta htt ...
- 1.环境搭建-mysql+tomcat+myeclipse安装并配置
一.安装mysql数据库并配置 下载地址:https://pan.baidu.com/s/1OJ3ggda7Cthl4GCxWKbTng 密码:sd6b 1.打开安装程序