forked from rajatgoyal715/Hackerrank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReverseShuffleMerge.java
More file actions
28 lines (27 loc) · 849 Bytes
/
ReverseShuffleMerge.java
File metadata and controls
28 lines (27 loc) · 849 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
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
// String s1 = s.substring(0, s.length()/2);
// String s2 = s.substring(s.length()/2);
String str="";
// char a[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int count[] = new int[26];
for(int i=0;i<s.length();i++){
count[s.charAt(i)-97]++;
}
for(int i=0;i<26;i++){
int temp = count[i]/2;
while(temp!=0){
str = str + (char)(i+97);
temp--;
}
}
System.out.println(str);
}
}