当前位置: 首页 > news >正文

品牌型网站制作公司中国免费域名注册平台

品牌型网站制作公司,中国免费域名注册平台,蚌埠seo外包,网站建设平台多少钱力扣题-12.2 [力扣刷题攻略] Re:从零开始的力扣刷题生活 力扣题1:423. 从英文中重建数字 解题思想:有的单词通过一个字母就可以确定,依次确定即可 class Solution(object):def originalDigits(self, s):""":typ…

力扣题-12.2

[力扣刷题攻略] Re:从零开始的力扣刷题生活

力扣题1:423. 从英文中重建数字

解题思想:有的单词通过一个字母就可以确定,依次确定即可

在这里插入图片描述

class Solution(object):def originalDigits(self, s):""":type s: str:rtype: str"""char_count = {}t = 'egfihonsrutwvxz'for i in range(len(t)):char_count[t[i]] = 0for i in range(len(s)):if s[i] in char_count:char_count[s[i]] += 1else:char_count[s[i]] = 1result = []if char_count['z']!=0:for i in range(char_count['z']):result.append(0)temp = 'zero'for i in range(len(temp)):char_count[temp[i]] -=1if char_count['x']!=0:for i in range(char_count['x']):result.append(6)temp = 'six'for i in range(len(temp)):char_count[temp[i]] -=1if char_count['w']!=0:for i in range(char_count['w']):result.append(2)temp = 'two'for i in range(len(temp)):char_count[temp[i]] -=1if char_count['g']!=0:for i in range(char_count['g']):result.append(8)temp = 'eight'for i in range(len(temp)):char_count[temp[i]] -=1if char_count['s']!=0:for i in range(char_count['s']):result.append(7)temp = 'seven'for i in range(len(temp)):char_count[temp[i]] -=1if char_count['h']!=0:for i in range(char_count['h']):result.append(3)temp = 'three'for i in range(len(temp)):char_count[temp[i]] -=1if char_count['v']!=0:for i in range(char_count['v']):result.append(5)temp = 'five'for i in range(len(temp)):char_count[temp[i]] -=1if char_count['f']!=0:for i in range(char_count['f']):result.append(4)temp = 'four'for i in range(len(temp)):char_count[temp[i]] -=1if char_count['o']!=0:for i in range(char_count['o']):result.append(1)temp = 'one'for i in range(len(temp)):char_count[temp[i]] -=1if char_count['i']!=0:for i in range(char_count['i']):result.append(9)temp = 'nine'for i in range(len(temp)):char_count[temp[i]] -=1return ''.join(map(str, sorted(result)))
class Solution {
public:std::string originalDigits(std::string s) {std::unordered_map<char, int> charCount;std::string t = "egfihonsrutwvxz";for (char c : t) {charCount[c] = 0;}for (char c : s) {if (charCount.find(c) != charCount.end()) {charCount[c] += 1;}}std::vector<int> result;if (charCount['z'] != 0) {int count = charCount['z'];for (int i = 0; i < count; ++i) {result.push_back(0);std::string temp = "zero";for (char c : temp) {charCount[c] -= 1;}}}if (charCount['x'] != 0) {int count = charCount['x'];for (int i = 0; i < count; ++i) {result.push_back(6);std::string temp = "six";for (char c : temp) {charCount[c] -= 1;}}}if (charCount['w'] != 0) {int count = charCount['w'];for (int i = 0; i < count; ++i) {result.push_back(2);std::string temp = "two";for (char c : temp) {charCount[c] -= 1;}}}if (charCount['g'] != 0) {int count = charCount['g'];for (int i = 0; i < count; ++i) {result.push_back(8);std::string temp = "eight";for (char c : temp) {charCount[c] -= 1;}}}if (charCount['s'] != 0) {int count = charCount['s'];for (int i = 0; i < count; ++i) {result.push_back(7);std::string temp = "seven";for (char c : temp) {charCount[c] -= 1;}}}if (charCount['h'] != 0) {int count = charCount['h'];for (int i = 0; i < count; ++i) {result.push_back(3);std::string temp = "three";for (char c : temp) {charCount[c] -= 1;}}}if (charCount['v'] != 0) {int count = charCount['v'];for (int i = 0; i < count; ++i) {result.push_back(5);std::string temp = "five";for (char c : temp) {charCount[c] -= 1;}}}if (charCount['f'] != 0) {int count = charCount['f'];for (int i = 0; i < count; ++i) {result.push_back(4);std::string temp = "four";for (char c : temp) {charCount[c] -= 1;}}}if (charCount['o'] != 0) {int count = charCount['o'];for (int i = 0; i < count; ++i) {result.push_back(1);std::string temp = "one";for (char c : temp) {charCount[c] -= 1;}}}if (charCount['i'] != 0) {int count = charCount['i'];for (int i = 0; i < count; ++i) {result.push_back(9);std::string temp = "nine";for (char c : temp) {charCount[c] -= 1;}}}std::sort(result.begin(), result.end());std::string resultString;for (int digit : result) {resultString += std::to_string(digit);}return resultString;}
};
http://www.tj-hxxt.cn/news/64685.html

相关文章:

  • 优化政府门户网站建设信息流广告投放流程
  • 五星花园网站建设兼职2024年新闻摘抄
  • 乌鲁木齐网站建设公司seo是干嘛的
  • 手机版网站建设开发怎么制作网页设计
  • 哪些网站可以医生做兼职最火的网络推广平台
  • 怎么学做淘宝电商网站吗成都网站seo设计
  • 河北中石化建设网站页面设计漂亮的网站
  • 沈阳网站制作服务网络推广方法有几种
  • 江苏省城乡与建设厅网站济南网站优化公司
  • wordpress weixin百度seo发包工具
  • 南宁伯才网络公司做网站好吗南昌seo招聘信息
  • 网站怎么做移动图片不显示不出来吗网络营销特点
  • 怎么做企业曝光引流网站seo概念的理解
  • 做网站服务器多钱怎样注册一个自己的平台
  • 租车网站制作方案水果营销软文
  • 做文字头像的网站国际新闻头条最新消息
  • 商场大型话题活动策划网站软文写作兼职
  • 网站模板文件不存在网站优化推广价格
  • 有经验的合肥网站建设保定seo网站推广
  • 前程无忧网广州网站建设分类岗位公司网站设计定制
  • 网站建设培训珠海自助发稿
  • 教育行业网站设计百度小说排行榜2019
  • 凯里做网站做网络推广为什么会被抓
  • 个人介绍网站怎么做千万别在百度上搜别人名字
  • 自适应网站一般做几个尺寸深圳营销型网站定制
  • wordpress wp_trim_words沧州seo公司
  • 网站服务器容器semir
  • 网站开发项目立项报告范文国内免费二级域名建站
  • 网站的月度流量统计报告怎么做郑州seo优化外包公司
  • 微信公众号是干什么用的深圳网站优化排名