forked from rmkcodingclub/AmazonProblems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproblem1.java
56 lines (49 loc) · 915 Bytes
/
problem1.java
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
Solved by Manikandan, Dept of CSE
*/
package javaapplication1;
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
String s=in.nextLine();
char a=naresh(s);
System.out.println(a);
}
public static Character naresh(String e)
{
HashMap<Character,Integer> d=new HashMap<Character,Integer>();
int i,j;
Character c;
j=e.length();
for(i=0;i<j;i++)
{
c=e.charAt(i);
if(d.containsKey(c))
d.put(c,d.get(c)+1);
else
d.put(c,1);
}
for(i=0;i<j;i++)
{
c=e.charAt(i);
if(d.get(c)==1)
return c;
}
return null;
}
}
/**
* Solution by Akila J, CSE
*/
import java.io.*;
public class RegexTestStrings
{
public static final String EXAMPLE_TEST = "This is my small example " + "string which I'm going to " + "use for pattern matching.";
public static void main(String[] args)
{
System.out.println(EXAMPLE_TEST.matches("^b*[a-z][a-z][a-z]$"));
}
}