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的更多相关文章

  1. 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 ...

  2. [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 ...

  3. LeetCode 345

    Reverse Vowels of a String Write a function that takes a string as input and reverse only the vowels ...

随机推荐

  1. 推荐 Laravel API 项目必须使用的 8 个扩展包

    如今在现代网络开发中,比较流行的模式是基于 API 开发,可以通过手机或网站来创建服务. Laravel 是创建基于 API 的项目的最佳框架之一,它为世界各地的大型社区提供了高速开发. Larave ...

  2. 【MVC】Model的使用

    1,Model的职责: Model只负责与数据处理相关的工作. 2,开发Model的基本观念 采用ORM信息访问技术开发 ORM是将结构化的关系型数据,映射成面向对象模型.对于EF来说,就是关系型数据 ...

  3. FormData 知识点

    通过FormData对象可以组装一组用 XMLHttpRequest发送请求的键/值对.它可以更灵活方便的发送表单数据,因此可以独立于表单使用. 如果你把表单的编码类型设置为multipart/for ...

  4. ionic使用常见问题(八)——PHP无法获取$http的post数据

    一个简单的post请求 $http.post('do-submit.php',myData) .success(function(){ // some code });   可是,用angularjs ...

  5. Linq快速入门——扩展方法

    Linq为我们提供了许多扩展方法,方便我们对数据源进行操作(Where,Select...).即使你不了解算法,也能使用Linq当回牛人.扩展方法本质并不是什么高深的技术,说白了就是一个Static静 ...

  6. protobuf 协议 windows 下 C++ 环境搭建

    1. 下载protobuf https://code.google.com/p/protobuf/downloads/list Protocol Buffers 2.5.0 full source - ...

  7. POSIX 消息队列 之 概述 链接方式

    NAMEmq_overview —— POSIX消息队列概述 DESCRIPTIONPOSIX消息队列允许进程以消息的形式交换数据.此API与System V消息队列(msgget(2),msgsnd ...

  8. react组件的创建

    最近项目接触react和rn,之前会一些vue和小程序,起初写react是很难受的,尤其是jsx的写法,不过2周过后感觉写起来有点舒服了... 目前react的组件一共有3种方式:React.crea ...

  9. Guid 几种格式化

    //32 位数字:00000000000000000000000000000000 Console.WriteLine(Guid.NewGuid().ToString("N")); ...

  10. A request has been denied as a potential CSRF attack错误解决方法

    2018-05-30 13:40:50 [http-nio-8081-exec-3] [ERROR] com.opensymphony.xwork2.interceptor.ParametersInt ...