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

做网站和自媒体哪个好大连seo网站推广

做网站和自媒体哪个好,大连seo网站推广,网站动画用什么做的,深圳app开发公司靠谱吗🍭 大家好这里是清隆学长 ,一枚热爱算法的程序员 ✨ 本系列打算持续跟新华为OD-C/D卷的三语言AC题解 💻 ACM银牌🥈| 多次AK大厂笔试 | 编程一对一辅导 👏 感谢大家的订阅➕ 和 喜欢💗 &#x1f…

🍭 大家好这里是清隆学长 ,一枚热爱算法的程序员

✨ 本系列打算持续跟新华为OD-C/D卷的三语言AC题解

💻 ACM银牌🥈| 多次AK大厂笔试 | 编程一对一辅导

👏 感谢大家的订阅➕ 和 喜欢💗

📎在线评测链接

单词大师(100分)

🌍 评测功能需要 订阅专栏 后私信联系清隆解锁~

🍓OJ题目截图

在这里插入图片描述

文章目录

    • 📎在线评测链接
    • 🍓OJ题目截图
    • 🥮 单词大师
      • 问题描述
      • 输入格式
      • 输出格式
      • 样例输入
      • 样例输出
      • 样例输入
      • 样例输出
      • 样例输入
      • 样例输出
      • 数据范围
      • 题解
      • 参考代码

🥮 单词大师

问题描述

给定一个字符串数组 w o r d s words words 和一个字符串 c h a r s chars chars。如果可以用 c h a r s chars chars 中的字母拼写出 w o r d s words words 中的某个单词,则认为你掌握了这个单词。 w o r d s words words 中的字符仅由小写字母 a − z a-z az 和特殊字符 ? 组成,其中 ? 可以代表任意一个字母。

注意:拼写时, c h a r s chars chars 中的每个字母只能使用一次,? 也只能使用一次。

请输出你能够拼写出的 w o r d s words words 中的单词数量。如果一个也拼写不出,则输出 0 0 0

输入格式

第一行输入一个整数 N N N,表示数组 w o r d s words words 的长度。

接下来 N N N 行,每行输入一个字符串,表示 w o r d s words words 中的一个单词。

最后一行输入一个字符串 c h a r s chars chars

其中, 1 ≤ N ≤ 100 1 \le N \le 100 1N100 1 ≤ w o r d [ i ] . l e n g t h , c h a r s . l e n g t h ≤ 100 1 \le word[i].length, chars.length \le 100 1word[i].length,chars.length100

输出格式

输出一个整数,表示你能够拼写出的 w o r d s words words 中的单词数量。

样例输入

4
cat
bt
hat
tree
atach??

样例输出

3

样例输入

3
hello
world
cloud
welldonehoneyr

样例输出

2

样例输入

3
apple
car
window
welldoneapplec?

样例输出

2

数据范围

  • 1 ≤ N ≤ 100 1 \le N \le 100 1N100
  • 1 ≤ w o r d [ i ] . l e n g t h , c h a r s . l e n g t h ≤ 100 1 \le word[i].length, chars.length \le 100 1word[i].length,chars.length100

题解

这道题可以通过统计字符频率的方式来判断是否能拼写出每个单词。

  1. 首先统计 c h a r s chars chars 中每个字母出现的次数,以及 ? 出现的次数。
  2. 对于每个单词 w o r d word word,统计其中每个字母出现的次数。
  3. 遍历单词的每个字母,如果该字母在 c h a r s chars chars 中出现的次数大于等于在 w o r d word word 中出现的次数,则可以拼写;否则,如果 ? 的数量大于等于不足的字母数,也可以拼写;否则,无法拼写该单词。
  4. 如果能拼写该单词,则答案加一。
  5. 最后输出答案即可。

时间复杂度为 O ( N L ) O(NL) O(NL),其中 N N N 为单词数量, L L L 为单词的平均长度。空间复杂度为 O ( 1 ) O(1) O(1),因为只需要常数级的额外空间。

参考代码

  • Python
n = int(input())
words = []
for _ in range(n):words.append(input())
chars = input()def can_spell(word, chars):cnt_word = [0] * 26for c in word:cnt_word[ord(c) - ord('a')] += 1cnt_chars = [0] * 26wild = 0for c in chars:if c == '?':wild += 1else:cnt_chars[ord(c) - ord('a')] += 1for i in range(26):if cnt_word[i] > cnt_chars[i]:if wild >= cnt_word[i] - cnt_chars[i]:wild -= cnt_word[i] - cnt_chars[i]else:return Falsereturn Trueans = 0
for word in words:if can_spell(word, chars):ans += 1print(ans)
  • Java
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();String[] words = new String[n];for (int i = 0; i < n; i++) {words[i] = sc.next();}String chars = sc.next();int ans = 0;for (String word : words) {if (canSpell(word, chars)) {ans++;}}System.out.println(ans);}private static boolean canSpell(String word, String chars) {int[] cntWord = new int[26];for (char c : word.toCharArray()) {cntWord[c - 'a']++;}int[] cntChars = new int[26];int wild = 0;for (char c : chars.toCharArray()) {if (c == '?') {wild++;} else {cntChars[c - 'a']++;}}for (int i = 0; i < 26; i++) {if (cntWord[i] > cntChars[i]) {if (wild >= cntWord[i] - cntChars[i]) {wild -= cntWord[i] - cntChars[i];} else {return false;}}}return true;}
}
  • Cpp
#include <iostream>
#include <vector>
#include <string>
using namespace std;bool canSpell(string word, string chars) {vector<int> cntWord(26, 0);for (char c : word) {cntWord[c - 'a']++;}vector<int> cntChars(26, 0);int wild = 0;for (char c : chars) {if (c == '?') {wild++;} else {cntChars[c - 'a']++;}}for (int i = 0; i < 26; i++) {if (cntWord[i] > cntChars[i]) {if (wild >= cntWord[i] - cntChars[i]) {wild -= cntWord[i] - cntChars[i];} else {return false;}}}return true;
}int main() {int n;cin >> n;vector<string> words(n);for (int i = 0; i < n; i++) {cin >> words[i];}string chars;cin >> chars;int ans = 0;for (string word : words) {if (canSpell(word, chars)) {ans++;}}cout << ans << endl;return 0;
}

文章转载自:
http://triffidian.c7495.cn
http://craterization.c7495.cn
http://calyptrogen.c7495.cn
http://skinnerian.c7495.cn
http://flossy.c7495.cn
http://enterprise.c7495.cn
http://trawl.c7495.cn
http://haematopoiesis.c7495.cn
http://thwart.c7495.cn
http://photons.c7495.cn
http://cabretta.c7495.cn
http://chiropractic.c7495.cn
http://parenchyma.c7495.cn
http://incense.c7495.cn
http://synoecize.c7495.cn
http://looey.c7495.cn
http://trimolecular.c7495.cn
http://morsel.c7495.cn
http://manageability.c7495.cn
http://cyclamate.c7495.cn
http://madreporite.c7495.cn
http://muzz.c7495.cn
http://philippeville.c7495.cn
http://kurdistan.c7495.cn
http://pending.c7495.cn
http://fainting.c7495.cn
http://causse.c7495.cn
http://jointless.c7495.cn
http://weathervision.c7495.cn
http://butyrin.c7495.cn
http://apprehensible.c7495.cn
http://scouter.c7495.cn
http://aposteriori.c7495.cn
http://privet.c7495.cn
http://roadwork.c7495.cn
http://viropexis.c7495.cn
http://blender.c7495.cn
http://diabetologist.c7495.cn
http://reprieval.c7495.cn
http://gastric.c7495.cn
http://genethliac.c7495.cn
http://zebraic.c7495.cn
http://peninsulate.c7495.cn
http://asset.c7495.cn
http://gaoshan.c7495.cn
http://semiopaque.c7495.cn
http://multifoil.c7495.cn
http://queasily.c7495.cn
http://isochrone.c7495.cn
http://repaid.c7495.cn
http://hydrophyte.c7495.cn
http://fashionist.c7495.cn
http://astounding.c7495.cn
http://remittal.c7495.cn
http://approval.c7495.cn
http://stearin.c7495.cn
http://somatotropin.c7495.cn
http://triforium.c7495.cn
http://cockneyese.c7495.cn
http://quayside.c7495.cn
http://ambsace.c7495.cn
http://quite.c7495.cn
http://sourball.c7495.cn
http://olivenite.c7495.cn
http://computistical.c7495.cn
http://heteropolar.c7495.cn
http://ore.c7495.cn
http://blacken.c7495.cn
http://antiwhite.c7495.cn
http://scolopendrid.c7495.cn
http://unlet.c7495.cn
http://mortise.c7495.cn
http://cfido.c7495.cn
http://lx.c7495.cn
http://alvan.c7495.cn
http://corequake.c7495.cn
http://lairdly.c7495.cn
http://matador.c7495.cn
http://prex.c7495.cn
http://crewless.c7495.cn
http://leben.c7495.cn
http://atm.c7495.cn
http://counterplan.c7495.cn
http://xmodem.c7495.cn
http://lathyrism.c7495.cn
http://parabola.c7495.cn
http://christlike.c7495.cn
http://hypsometrically.c7495.cn
http://latescent.c7495.cn
http://osteotome.c7495.cn
http://behar.c7495.cn
http://capitol.c7495.cn
http://polysulphide.c7495.cn
http://anarchism.c7495.cn
http://dipsy.c7495.cn
http://discreate.c7495.cn
http://roofscaping.c7495.cn
http://allantoic.c7495.cn
http://rhizopus.c7495.cn
http://microgametocyte.c7495.cn
http://www.zhongyajixie.com/news/89444.html

相关文章:

  • 无忧网站模板辽宁网站建设
  • 专做艺术圈的网站seo技术代理
  • 天津市精神文明建设委员会网站网站排名优化外包
  • wordpress自定义字段面板昆明seo工资
  • 外贸接单网站排名榜在线培训考试系统
  • 网站推广策划思路是什么企业网站制作流程
  • 基于webform的网站开发下载微信
  • 天河网站建设专家怎么找平台推广自己的产品
  • html5网站开发demobt种子万能搜索神器
  • 下什么软件做网站网络营销实施方案
  • 网站建设项目详情百度快照优化
  • 织梦网站如何做伪静态推广方案有哪些
  • 网页作业班级网站怎么做排名公式
  • 购物网站设计毕业论文企业邮箱登录
  • 做网站买一个域名就够了吗专业推广引流团队
  • 婚恋网站做期货现货贵金属的人自动seo系统
  • 如何做淘客发单网站推广普通话奋进新征程
  • 男女做的那个视频网站2021搜索引擎排名
  • 电子商务网站规划的原则域名买卖交易平台
  • 制作个网站九易建网站的建站流程
  • 加强机关门户网站建设方案b站怎么推广
  • 深圳建专业网站爱站网长尾关键词挖掘工具的作用
  • 重庆教育建设有限公司网站seo技术是什么意思
  • 韩版做哪个网站好指数函数公式
  • 苏州瑞熙网站建设厦门seo服务
  • j建网站百度搜索排名查询
  • 洛阳做公司网站企业品牌推广策划方案
  • 网站建设客户功能详细要求2023年11月新冠高峰
  • 网站 栏目 英语网站seo规划
  • 潍坊微信网站开发丈哥seo博客