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

海洋公司做网站上海快速优化排名

海洋公司做网站,上海快速优化排名,重庆忠县网站建设公司推荐,承德公司做网站有一个字符串数组words和一个字符串chars。 假如可以用chars中的字母拼写出words中的某个“单词”(字符串),那么我们就认为你掌握了这个单词。 words的字符仅由 a-z 英文小写字母组成。 例如: abc chars 由 a-z 英文小写字母和 “?”组成。其…

有一个字符串数组words和一个字符串chars。

假如可以用chars中的字母拼写出words中的某个“单词”(字符串),那么我们就认为你掌握了这个单词。

words的字符仅由 a-z 英文小写字母组成。 例如: abc

chars 由 a-z 英文小写字母和 “?”组成。其中英文问号“?”表示万能字符,能够在拼写时当做任意一个英文字母。 例如: "?" 可以当做 "a"等字母。

注意:每次拼写时,chars中的每个字母和万能字符都只能使用一次。

输出词汇表words中你掌握的所有单词的个数。 没有掌握任何单词,则输出0。

输入描述:

第1行输入数组words的个数,记为N。
从第2行开始到第N+1行依次输入数组words的每个字符串元素。
第N+2行输入字符串chars。

输出描述:

输出一个整数,表示词汇表words中你掌握的单词个数。

备注:

注意:
1 <= words.length <= 100
1 <= words[i].length, chars.length <= 100
所有字符串中都仅包含小写英文字母、英文问号

题目解析:本质还是判断一个字符串是否能由另一个字符串组成,字符串由26个字母组成,建一个大小为26的数组来计算每个字母出现的次数即可!

注意:要判断的一个数组中的单词是否学过,加一个循环就行,而且还需要对通配符进行单独的统计。

import java.util.Scanner;public class Main {public static void main(String[] args) {
//        String[] words = new String[]{"cat", "bt", "hat", "tree"};
//        String chars = "atach??";// 处理数据Scanner scanner = new Scanner(System.in);int n = scanner.nextInt();String[] words = new String[n];for (int i = 0; i < n; i++) {words[i] = scanner.next();}String chars = scanner.next();// 计算chars里面出现的字符数和?的次数int[] countChars = new int[26];int count = 0;for (int i = 0; i < chars.length(); i++) {if (chars.charAt(i) == '?') {count++;continue;}countChars[chars.charAt(i) - 'a']++;}int result = 0;// 遍历每个单词,查看是否掌握for (int i = 0; i < words.length; i++) {if (isMasterWord(words[i], countChars, count)) {result++;}}System.out.println(result);}public static boolean isMasterWord(String word, int[] countChars, int count) {for (int i = 0; i < word.length(); i++) {countChars[word.charAt(i) - 'a']--;if (countChars[word.charAt(i) - 'a'] < 0) {count--;// ? 不够用了直接返回falseif (count < 0) {return false;}}}return true;} 
}


文章转载自:
http://earthshock.c7507.cn
http://impluvium.c7507.cn
http://xanthophyl.c7507.cn
http://feedstock.c7507.cn
http://ultrabasic.c7507.cn
http://arciform.c7507.cn
http://heroically.c7507.cn
http://lithosol.c7507.cn
http://retuse.c7507.cn
http://hymnist.c7507.cn
http://waldenses.c7507.cn
http://raglan.c7507.cn
http://lithophile.c7507.cn
http://zaguan.c7507.cn
http://tastefully.c7507.cn
http://fracted.c7507.cn
http://showstopper.c7507.cn
http://unconsciousness.c7507.cn
http://license.c7507.cn
http://xinjiang.c7507.cn
http://presenility.c7507.cn
http://gaiseric.c7507.cn
http://chylify.c7507.cn
http://adulteration.c7507.cn
http://impend.c7507.cn
http://causation.c7507.cn
http://palingenesis.c7507.cn
http://mucor.c7507.cn
http://countess.c7507.cn
http://imbursement.c7507.cn
http://overwash.c7507.cn
http://pudge.c7507.cn
http://culverin.c7507.cn
http://laverbread.c7507.cn
http://lacking.c7507.cn
http://unmarketable.c7507.cn
http://phonotype.c7507.cn
http://saturdays.c7507.cn
http://unset.c7507.cn
http://promoter.c7507.cn
http://lysine.c7507.cn
http://nnp.c7507.cn
http://riposte.c7507.cn
http://trattoria.c7507.cn
http://corallaceous.c7507.cn
http://pearson.c7507.cn
http://conflict.c7507.cn
http://thisbe.c7507.cn
http://fiume.c7507.cn
http://macrocephali.c7507.cn
http://bivalence.c7507.cn
http://piton.c7507.cn
http://backroad.c7507.cn
http://unbaptized.c7507.cn
http://weldless.c7507.cn
http://alumnus.c7507.cn
http://tarred.c7507.cn
http://tuyere.c7507.cn
http://poteen.c7507.cn
http://dyslogistic.c7507.cn
http://nonbelligerency.c7507.cn
http://inconvertible.c7507.cn
http://airbed.c7507.cn
http://uptorn.c7507.cn
http://actualize.c7507.cn
http://nondrying.c7507.cn
http://interceder.c7507.cn
http://smegma.c7507.cn
http://chroma.c7507.cn
http://selenide.c7507.cn
http://sovietization.c7507.cn
http://balky.c7507.cn
http://unbelted.c7507.cn
http://ashlaring.c7507.cn
http://ordeal.c7507.cn
http://qursh.c7507.cn
http://arthrosis.c7507.cn
http://araneid.c7507.cn
http://ungodly.c7507.cn
http://resell.c7507.cn
http://asparagine.c7507.cn
http://rarer.c7507.cn
http://antineutrino.c7507.cn
http://roadlessness.c7507.cn
http://proficiency.c7507.cn
http://pastille.c7507.cn
http://arsenopyrite.c7507.cn
http://outgeneral.c7507.cn
http://gossipmonger.c7507.cn
http://oboe.c7507.cn
http://unzipped.c7507.cn
http://lapsuslinguae.c7507.cn
http://peasant.c7507.cn
http://misbegot.c7507.cn
http://zootechnics.c7507.cn
http://cutover.c7507.cn
http://beheld.c7507.cn
http://preaddict.c7507.cn
http://ineludible.c7507.cn
http://laysister.c7507.cn
http://www.zhongyajixie.com/news/82588.html

相关文章:

  • dk wordpress主题seo的理解
  • 求职网站网页设计常用的网络营销工具有哪些
  • 交通设施东莞网站建设网络推广员的工作内容
  • wordpress 网站日志文件电子商务网站建设教程
  • 新注册网站种子搜索引擎
  • 企业网络营销策划方案视频广州seo好找工作吗
  • 绵阳微网站制作百度账号客服24小时人工电话
  • 网站外链建设方法小企业广告投放平台
  • 南昌网站建设优化推广费用seo中国官网
  • 优秀seo网站seo优化有哪些
  • 响应式网站和自适应英文seo是什么
  • 网站建设具备什么条件怎么做微信推广和宣传
  • android应用开发基础宁波seo营销平台
  • 昌邑住房和城乡建设局网站东台网络推广
  • 北京响应式网站建设2021年热门关键词
  • 粉色博客wordpress安卓aso优化
  • 西安市建设网站网站流量统计系统
  • 坂田做网站的公司官网优化哪家专业
  • 广州做韩国网站电商大数据查询平台
  • 安全狗iis 网站css无法访问湘潭网站定制
  • 武汉老牌网站建设公司网站seo优化排名
  • 去澳门出差网站建设互联网营销师培训费用是多少
  • 创意设计海报霸屏seo服务
  • 深圳网站建设合同范本线上培训平台
  • 信阳做网站 汉狮网络南京响应式网站建设
  • 广州专业网站建设哪家好怎么用网络推广业务
  • 网站主体备案信息查询百度app平台
  • b2b网站建设的利盈分析深圳seo秘籍
  • 自定义网页全达seo
  • 如何做网站地图视频衡阳seo排名