首页 > 试题广场 >

删除公共字符

[编程题]删除公共字符
  • 热度指数:49037 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解
输入两个字符串,从第一字符串中删除第二个字符串中所有的字符。例如,输入”They are students.”和”aeiou”,则删除之后的第一个字符串变成”Thy r stdnts.”

输入描述:
每个测试输入包含2个字符串


输出描述:
输出删除后的字符串
示例1

输入

They are students. 
aeiou

输出

Thy r stdnts.
头像 牛客145577827号
发表于 2022-06-12 08:44:55
import java.util.*; public class Main{     public static void main(String [] args){   展开全文
头像 星不离月
发表于 2022-10-14 15:17:54
import java.util.*; // 用哈希存储第二个字符串的每个字符出现的次数,有就+1; // 用第一个字符串的每一个字符一一1对比,为null则保持下来 public class Main {   &nb 展开全文
头像 是暗恋懒羊羊呀
发表于 2023-07-18 16:36:40
#include <stdio.h> int main() { char str1[100] ={0}; char str2[100] = {0}; gets(str1); gets(str2); char * s1 = str1; 展开全文
头像 戊子仲秋
发表于 2023-03-21 19:09:49
#include <iostream> using namespace std; #include <string> int main() { string s; string c; getline(cin, s); getline(cin 展开全文
头像 写日记真的很犯困
发表于 2023-11-02 23:19:36
#include <stdio.h> #include <string.h> int main() { char str1[100] ; char str2[100] ; scanf("%[^\n]", str1); getchar(); sca 展开全文
头像 阿贝尔的日记
发表于 2022-09-06 11:29:12
一、暴力循环 去str1里面找str2的值,然后erase。 时间复杂度 #include <iostream> #include <string> using namespace std; int main() { string str1, str2; 展开全文
头像 可可弟弟
发表于 2019-08-21 16:12:30
1.将第二个字母用hash表存下来2.遍历第一个字符串,然后hash.count(s)来判断是否为第二个字符串中的数字,开一个答案res的字符串,如果没有在字符串2中出现,就加到答案中去。 #include <iostream> #include <algorithm> #i 展开全文
头像 风度翩翩的单身狗很热情
发表于 2023-09-14 23:09:41
import java.util.*; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new S 展开全文
头像 ZackHuang1
发表于 2023-07-18 21:52:51
#include <stdio.h> int Check(char a , char* p) { int i = 0; while(*(p + i)) { if(a == *(p + i)) return 1; 展开全文
头像 佛系的小龙虾在研究求职打法
发表于 2023-04-05 11:14:32
#include <stdio.h> #include<string.h> int if_exit(char arr1, char* str2) { while (*str2) { if (arr1 == *str2) { return 0; } s 展开全文