当前位置:网站首页>Bull: remove common characters
Bull: remove common characters
2022-07-30 07:42:00 【HDLaZy】
题目描述:
解题思路:
使用Java的HashMap集合框架,HashMap无重复值,将字符串2each character of the,然后遍历字符串1的每一个字符,判断map中是否存在该值,If it does not exist, it will be concatenated into a new string,No splicing if present.
代码:
import java.util.*;
public class Main{
public static void main (String[] args){
Scanner scan = new Scanner(System.in);
String str1 = scan.nextLine();
String str2 = scan.nextLine();
HashMap<Character,Integer> map = new HashMap<> ();
for(int i=0; i< str2.length() ;i++){
if( map.get( str2.charAt(i))== null){
map.put(str2.charAt(i),1);
}else{
map.put(str2.charAt(i),map.get(str2.charAt(i))+1);
}
}
String result="";
for(int i=0; i< str1.length() ; i++){
if(map.get(str1.charAt(i))==null){
result+=str1.charAt(i);
}
}
System.out.println(result);
}
}
边栏推荐
- How to create a shortcut without the "shortcut" suffix?
- 一种分布式深度学习编程新范式:Global Tensor
- From installation to compilation: 10 minutes to teach you to use and develop GraphScope locally
- 大厂年薪50w+招聘具有测试平台开发能力的测试工程师
- 2021-05-26
- Biotin-SS-NHS ester|生物素-二硫键-活性酯|CAS:122266-55-1具有良好的水溶性
- 如何使用xilinx的FFT ip
- GNNLab: A Novel GNN System Based on Spatial Sharing Ideas
- 掌握JESD204B(二)–AD6676的调试
- 测试开发工程师成长日记018 - 测试面试必备题记录(持续更新)
猜你喜欢
Ingress:从静态图分析到动态图分析
Test and Development Engineer Growth Diary 009 - Environment Pai Pai Station: Development Environment, Test Environment, Production Environment, UAT Environment, Simulation Environment
Network Protocol 01 - Basic Concepts
Rapidly develop GraphScope graph analysis applications
图扑数字孪生青岛城轨,赋能智慧交通低碳发展
比尔·盖茨买百万亩农地成美“头号地主”,图扑数字孪生农场
Biotinyl Cystamine_CAS:128915-82-2_生物素半胱胺
A New Paradigm for Distributed Deep Learning Programming: Global Tensor
软件测试开发:发送第一封测试报告邮件
D-Desthiobiotin|D-脱硫生物素|CAS:533-48-2用于蛋白质和细胞的标记
随机推荐
Alamofire source code analysis - POST request
prometheus-basic_auth加密配置
Test and Development Engineer Growth Diary 009 - Environment Pai Pai Station: Development Environment, Test Environment, Production Environment, UAT Environment, Simulation Environment
网络协议01 - 基础概念
prometheus-tls加密
Test Development Engineer Growth Diary 017 - The Life Cycle of a Bug
测试开发工程师成长日记018 - 测试面试必备题记录(持续更新)
Devops基本概念和原理
Vineyard: 开源分布式内存数据管理框架
MongoDB-介绍,数据类型,基本语句
Network Protocol 01 - Basic Concepts
SE_01
arthas常用命令
mysql常用命令以及mysqldump备份
基于 JupyterLab 插件在 GraphScope 中交互式构图
用于标记蛋白质和抗体的Biotin-LC-Sulfo-NHS|CAS:191671-46-2
04-packing and unpacking
牛客:删除公共字符
The Force Plan Microservices | Centralized Configuration Center Config Asymmetric Encryption and Security Management
Shortcut keys commonly used in the use of Word