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 ...
随机推荐
- LG3369 【模板】普通平衡树
题意 您需要写一种数据结构(可参考题目标题),来维护一些数,其中需要提供以下操作: 插入x数 删除x数(若有多个相同的数,因只删除一个) 查询x数的排名(排名定义为比当前数小的数的个数+1.若有多个相 ...
- 用cmd加密文件夹
随着电脑的广泛应用,个人电脑的私人空间越来越大,很多人喜欢把个人的一些私隐的文件存放在电脑上,私隐文件当然是不想别人看到的,为了防止别人看不见自己的文件,可以有很多的方法,今天在网上看了一些文档,学会 ...
- mysql 事务隔离级别详解
事物的 隔离级别,说简单非常简单(新手也能说出 是个隔离级别 和 影响),说男也非常难.(很多 有几年编程 经验的程序员依旧搞不清楚) 废话不多少 直接开始: 事务的隔离级别 是用来描述 事务的读关系 ...
- 什么是Map-Reduce
Map-Reduce本身并不是算法:而是一种处理模式:因为在大数据分布式这种场景下,处理数据运算和单机版不同:需要协同多台机器,并行计算:于是有了map-reduce这种模式,map阶段是数据处理,在 ...
- 【python】break和continue
break:跳出循环 ,continue:停止当前循环,进入下一次循环,但为跳出循环. passwdList=["123","456"] valid = Fal ...
- Django mark_safe
不用mark_safe: 用mark_safe: 用法: from django.shortcuts import render from django.utils.safestring import ...
- css-深入理解margin和padding
最近一阶段从新学习了css,发现真的有很多很多的地方都是空白的,今天我们来总结一下margin和padding的一些不为人知的秘密! 一利用float和margin实现布局 我们首先来实现一个两列示布 ...
- 杂项:flex (adobe flex)
ylbtech-杂项:Flex (Adobe Flex) Flex指Adobe Flex,基于其专有的Macromedia Flash平台,它是涵盖了支持RIA(Rich Internet Appli ...
- ubuntu 14.04 lamp 安装与配置
一.安装apache 1.打开终端:Ctrl+Alt+T sudo apt-get update 2.通过apt-get方式安装Apache: sudo apt-get install apache2 ...
- JpGraph使用详解之中文乱码解决方法
在前面的JpGraph使用详解这篇文章,已经对JpGraph的使用方法作了详细的交代,前面说好的,接下来解决中文乱码. JpGraph为什么会出现中文乱码 在JpGraph中默认是要把字符串转成utf ...