首页 > 试题广场 >

字符串字符匹配

[编程题]字符串字符匹配
  • 热度指数:177656 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解
\hspace{15pt}对于给定的字符串 st,检查 s 中的所有字符是否都在 t 中出现。

输入描述:
\hspace{15pt}第一行输入一个长度为 1 \leqq {\rm len}(s) \leqq 200、仅由小写字母组成的字符串 s
\hspace{15pt}第二行输入一个长度为 1 \leqq {\rm len}(t) \leqq 200、仅由小写字母组成的字符串 t


输出描述:
\hspace{15pt}如果 s 中的所有字符都在 t 中出现,则输出 \rm true,否则输出 \rm false
示例1

输入

bc
abc

输出

true

备注:
\hspace{15pt}本题数据已规范为单组询问(2025/01/15)。
头像 BSF
发表于 2021-10-18 19:26:06
while True: try: S, T = input(), input() if set(S) & set(T) == set(S): print('true') else: pri 展开全文
头像 空中转体一周半
发表于 2022-05-03 19:35:58
用Set走捷径!把短字符串的字符加入到Set中,把长字符的字符从Set中剔除,如果最后Set为空,则满足条件。 public class Main { public static void main(String[] args) { Scanner in = new Scan 展开全文
头像 小陆要懂云
发表于 2021-08-19 10:16:37
#include <iostream> #include <string> #include <unordered_set> using namespace std; int main(){ string shortS,longS; bool re 展开全文
头像 派仔
发表于 2020-08-11 17:43:00
Set 轻松解决 import java.util.*; public class Main { public Main() { } public boolean isAllCharExist(String pShortString, String pLongStrin 展开全文
头像 牛客8008419号
发表于 2021-12-16 01:03:33
```while True: try: str1 = list(input()) str2 = list(input()) for i in str1: if i not in str2: 展开全文
头像 qybkb24
发表于 2021-11-17 20:03:01
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc 展开全文
头像 牛客374676145号
发表于 2022-03-05 20:37:56
while 1: try: s,l = set(input()), set(input()) if s & l == s: print('true') else: print('false') except: b 展开全文
头像 加油嘞
发表于 2022-03-13 22:41:24
#include<stdio.h> #include<string.h> int main(){ char data[200]; char str[200]; int num,len,i,j; while(scanf("%s",&dat 展开全文
头像 阿亮阿亮来了呀
发表于 2022-03-01 13:35:15
/** * 解题思路 * 1.循环接收输入的字符串 * 2.将短字符串截成数组 * 3.判断长字符串中是否包含短字符串的每个字符,全部包含返回true,只要有一个不包含返回false */ public static void strCont 展开全文
头像 KrazyPhish
发表于 2022-04-12 22:48:45
Array.every()用于对数组每个值遍历,且按回调函数的规则返回结果true/false,结果条件必须是数组中的所有值都满足,则该方法返回值才为true 与之相反的是Array.some()方法,同样遍历数组,但只需有一个满足条件即可返回true let str = readline().sp 展开全文