Skip to content

Commit 80d81ba

Browse files
committed
Create problem1.java
1 parent d1e499e commit 80d81ba

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

problem1.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
Solved by Manikandan, Dept of CSE
3+
*/
4+
5+
package javaapplication1;
6+
import java.util.*;
7+
public class Main
8+
{
9+
public static void main(String args[])
10+
{
11+
Scanner in=new Scanner(System.in);
12+
String s=in.nextLine();
13+
char a=naresh(s);
14+
System.out.println(a);
15+
}
16+
public static Character naresh(String e)
17+
{
18+
HashMap<Character,Integer> d=new HashMap<Character,Integer>();
19+
int i,j;
20+
Character c;
21+
j=e.length();
22+
for(i=0;i<j;i++)
23+
{
24+
c=e.charAt(i);
25+
if(d.containsKey(c))
26+
d.put(c,d.get(c)+1);
27+
else
28+
d.put(c,1);
29+
}
30+
for(i=0;i<j;i++)
31+
{
32+
c=e.charAt(i);
33+
if(d.get(c)==1)
34+
return c;
35+
}
36+
return null;
37+
}
38+
}
39+
40+

0 commit comments

Comments
 (0)