-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDevice Name System
More file actions
38 lines (36 loc) · 995 Bytes
/
Device Name System
File metadata and controls
38 lines (36 loc) · 995 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
36
37
38
// Online Java Compiler
// Use this editor to write, compile and run your Java code online
import java.util.*;
class HelloWorld {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
Map<String,Integer> m1=new HashMap<String,Integer>();
int n=sc.nextInt();
for(int i=0;i<n;i++)
{
String str=sc.next();
if(m1.containsKey(str))
{
int count=m1.get(str);
count=count+1;
m1.put(str,count);
}
else
{
m1.put(str,1);
}
}
Set s=m1.entrySet();
Iterator itr=s.iterator();
while(itr.hasNext())
{
Map.Entry m=(Map.Entry)itr.next();
int value=(Integer)m.getValue();
System.out.println(m.getKey());
for( int i=1;i<value;i++){
System.out.println(m.getKey()+""+i);
value--;
}
}
}
}