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 ...
随机推荐
- Assert随笔
☆ Assert.notNull(haha, "未找到需要导入的计划1");//haha必须不能为null,if为null则抛出message的异常: Assert.hasText ...
- Vue中的“混合”——mixins使用方法
混合是一种灵活的分布式复用 Vue 组件的方式.混合对象可以包含任意组件选项.以组件使用混合对象时,所有混合对象的选项将被混入该组件本身的选项.当组件和混合对象含有同名选项时,这些选项将以恰当的方式混 ...
- 12 Factor CLI Apps
CLIs are a fantastic way to build products. Unlike web applications, they take a small fraction of t ...
- 比jsonpath 更方便的json 数据查询JMESPath 使用
类似xml 的xpath json 有jsonpath 都是为了方便进行数据查询,但是jsonpath 的功能 并不是很强大,如果为了方便查询可以使用jmespath. 以下为简单使用: 查询格式 ...
- 批处理(bat)命令学习的一些总结
这篇笔记是我对批处理学习的一些总结,能在系统帮助里找到的内容我就不写了,太偏门的也不写,只写些个人感觉很好用的技巧,大部分属于整理 一.set 篇: 1.set(无开关) set .=test set ...
- oracle之 变更OS时间对数据库的影响
本文:说明提供了操作系统日期变更对数据库.应用程序数据和作业的影响. 1.它将会影响插入的任何记录,如果涉及到sysdate,则更改日期.2.它还会影响在那个日期运行的任何调度器作业. 如果将系统时间 ...
- spring cloud 之 Eureka 知识点
Eureka原理 当服务消费者想要调用服务提供者的API时,首先会在注册中心中查询当前可用的实例的网络地址(也可能是定时查询可用实例,本地缓存好可用服务列表),然后再使用客户端负载均衡,命中到其中一个 ...
- postman环境变量的设置
相同的api接口因为部署环境不同,分为test和fromal 不仅重复,还容易出错 下面来介绍一下Postman的一个小技巧来解决这种问题: 设置环境变量 Tips: 不是在OS中设置环境变量哦 ...
- FineUI中在一个页面中通过控件事件(JS)向父页面中添加Tab页
1.在前台页面尾部添加js代码 </form> <script type="text/javascript"> var basePath ...
- POJ2127 LICS模板
题目:http://poj.org/problem?id=2127 十分费劲地终于记录好了路径……用一个前驱. 这是 n^2 的LICS方法.其实就是 n ^ 2 log n 把“找之前的d [ j ...