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 ...
随机推荐
- shell 命令学习
https://blog.csdn.net/mnmlist/article/details/55215158
- 【正则表达式】java应用正则表达式
一:简单应用 /** * * ' * & * ' * & * & * ' * ' * ' * sources=sdcg'hde&xyz'dfa&&ad' ...
- WPF 带CheckBox、图标的TreeView(转)
在WPF实际项目开发的时候,经常会用到带CheckBox的TreeView,虽然微软在WPF的TreeView中没有提供该功能,但是微软在WPF中提供强大的ItemTemplate模板功能和自定义样式 ...
- OASGraph 转换rest api graphql 试用
创建rest api lb4 appdemo 参考提示即可 安装 OASGraph git clone https://github.com/strongloop/oasgraph.git cd oa ...
- benthos 几个方便的帮助命令
benthos 的命令行帮助做的是比较方便的,基本上就是一个自包含的帮助文档 全部命令 benthos --help 查询系统支持的caches benthos -list-caches 说明 使用帮 ...
- 关于 Cookie-free Domains (为什么将静态图片,js,css存放到单独的域名?)
这篇文章对高性能web开发具有参考性:http://developer.yahoo.com/performance/rules.html 本文主要描述使用裸域名做网站主域名时,如何用子域名做 cook ...
- 什么是Asp.net Core?和 .net core有什么区别?(转)
什么是Asp.Net core 我相信很多C# Developer已经对于.net core不算陌生了,就算没有正式使用相信也应该有所了解.微软在推出来.net core的同时为了方便一些原有的项目可 ...
- 嵌入式QT应用的窗口大小、位置,QtreeStack的样式
1. 窗口固定大小 :this->setFixedSize(452,244); 2.窗口固定位置(经试验,触摸屏的鼠标事件不能有效使用) oldPos.setX((800-452)/2); ...
- 比较全面的MySQL优化参考(转)
上篇:) http://imysql.com/2015/05/24/mysql-optimization-reference-1.shtml 下篇:) http://imysql.com/2015/0 ...
- 白话 Java Bean
所谓的Java Bean,就是一个java类,编译后成为了一个后缀名是 .class的文件.这就是Java Bean,不就是Java类吗? 1. 什么是 Java Bean? 很多培训机构在讲java ...