leetcode423
public class Solution {
public string OriginalDigits(string s) {
int[] count = new int[];
for (int i = ; i < s.Length; i++)
{
char c = s[i];
if (c == 'z') count[]++;
if (c == 'w') count[]++;
if (c == 'x') count[]++;
if (c == 's') count[]++; //7-6
if (c == 'g') count[]++;
if (c == 'u') count[]++;
if (c == 'f') count[]++; //5-4
if (c == 'h') count[]++; //3-8
if (c == 'i') count[]++; //9-8-5-6
if (c == 'o') count[]++; //1-0-2-4
}
count[] -= count[];
count[] -= count[];
count[] -= count[];
count[] = count[] - count[] - count[] - count[];
count[] = count[] - count[] - count[] - count[];
StringBuilder sb = new StringBuilder();
for (int i = ; i <= ; i++)
{
for (int j = ; j < count[i]; j++)
{
sb.Append(i);
}
}
return sb.ToString();
}
}
https://leetcode.com/problems/reconstruct-original-digits-from-english/#/description
leetcode423的更多相关文章
- [Swift]LeetCode423. 从英文中重建数字 | Reconstruct Original Digits from English
Given a non-empty string containing an out-of-order English representation of digits 0-9, output the ...
随机推荐
- codeforces 705A:Hulk
Description Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely ta ...
- python 2 到 3 的新手坑
print 和 input print 我们在课程最开始的时候就讲过 print,在版本2的使用方法是: print 'this is version 2' 也可以是 print('this is v ...
- Python给数字前固定位数加零
python中有一个zfill方法用来给字符串前面补0,非常有用 n = " s = n.zfill(5) " zfill()也可以给负数补0 n = "-123&quo ...
- cell 配置
Cells Cell configuration options Configure the API (top-level) cell Configure the child cells Config ...
- spring: 使用Spring提供的JDBC模板(使用profiles选择数据源/使用基于JDBC驱动的数据源)
Spring提供的JDBC框架负责管理资源和异常处理,从而可以简化开发者的JDBC代码.开发者只需要编写写入和读取数据库相关的代码即可. 正如在之前的小节中论述过的,Spring将数据库访问过程中的模 ...
- 存储过程,游标,异常捕捉 try catch 实例代码
1.存储过程代码. (数据库是 AdventureWorks) 存储过程用来将错误信息插入到指定的表中. 在别的地方可以调用存储过程插入错误信息(下面部分代码 生成一个表,如果表已经存在就会插入错误 ...
- selenium webdriver如何添加cookie
一. webdriver中常用的cookie方法 webdriver中提供了操作cookie的相关方法: get_cookies() 获得cookie信息 add_c ...
- hdu 5242 Game(树链剖分,贪心¥)
Game Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- 性能差异 ASP.NET WebForm与ASP.NET MVC
一.为什么说 ASP.NET WebForm 比 ASP.NET MVC 要差? WebForm 顾名思义,微软一向主打简单化,窗体模式,拖拽控件就能做网站了, 然而这也引发了许多 Java 和 .N ...
- Java_脚本引擎_03_nashorn支持es6
一.前言 jdk1.8的nashorn 支持部分es6语法. 二.支持es6 jdk默认是关闭了对es6的支持的,想要开启对es6的支持,需要设置一下jvm参数: -Dnashorn.args=--l ...