笔试训练48天:删除公共字符

张开发
2026/4/18 5:52:50 15 分钟阅读

分享文章

笔试训练48天:删除公共字符
REAL507 删除公共字符https://www.nowcoder.com/practice/f0db4c36573d459cae44ac90b90c6212?tpId182tqId34789ru/exam/oj简单 通过率32.96% 时间限制1秒 空间限制32M知识点Java工程师字符串2017模拟C工程师描述输入两个字符串从第一字符串中删除第二个字符串中所有的字符。例如输入”They are students.”和”aeiou”则删除之后的第一个字符串变成”Thy r stdnts.”输入描述每个测试输入包含2个字符串输出描述删除后的字符串示例1输入They are students.aeiou输出Thy r stdnts.主要思路哈希表暴力解法#include iostream #include string using namespace std; int main() { string s,t; getline(cin,s); getline(cin,t); bool hash[300]{0}; for(char ch:t) { hash[ch]true; } for(auto ch:s) { if(!hash[ch]) { coutch; } } return 0; }

更多文章