-
Notifications
You must be signed in to change notification settings - Fork 0
/
YT25.java
73 lines (62 loc) · 1.54 KB
/
YT25.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import java.io.*;
class YT25
{
public static void main(String[] args)throws IOException
{
String str;
int L, x=0, temp=0, c=0;
InputStreamReader I = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(I);
System.out.println("Enter the string: ");
str=br.readLine().toUpperCase();
//Fill:Array
L=str.length();
int a[]= new int[L];
for(int i=0; i<L; i++)
{
a[x++]=str.charAt(i);
}
//Print Array
/*System.out.println("Result");
for(int i=0; i<L; i++)
{
System.out.print(a[i]+" ");
}*/
//sort
for(int i=0; i<L; i++)
{
for(int j=i+1; j<L; j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
//Display of sorted Array
/*System.out.println("\nSorted Result");
for(int i=0; i<L; i++)
{
System.out.print(a[i]+" ");
}*/
//check the occ
for(int i=0; i<L-1; i++)
{
if(a[i]==a[i+1])
{
c++;
break;
}
}
if(c==1)
{
System.out.println("\nNo Unique");
}
else
{
System.out.println("\nUnique String");
}
}
}