-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAmusingJoke.java
More file actions
35 lines (34 loc) · 842 Bytes
/
AmusingJoke.java
File metadata and controls
35 lines (34 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.*;
public class AmusingJoke {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String n1=sc.next();
String n2=sc.next();
String n3=sc.next();
Map<Character,Integer>mp=new HashMap<>();
for(int i=0;i<n1.length();i++)
{
mp.put(n1.charAt(i),mp.getOrDefault(n1.charAt(i), 0)+1);
}
for(int i=0;i<n2.length();i++)
{
mp.put(n2.charAt(i),mp.getOrDefault(n2.charAt(i), 0)+1);
}
for(int i=0;i<n3.length();i++)
{
if(mp.get(n3.charAt(i))>1)
{
mp.put(n3.charAt(i),mp.get(n3.charAt(i))-1);
}
else if(mp.get(n3.charAt(i))==0)
{
mp.remove(n3.charAt(i));
}
}
if(mp.size()==0)
System.out.println("YES");
else
System.out.println("NO");
sc.close();
}
}