import
java.util.Arrays;
import
java.util.HashMap;
import
java.util.Map;
import
java.util.StringTokenizer;
class
Pair<K, V> {
private
K key;
private
V value;
public
Pair(K key, V value)
{
this
.key = key;
this
.value = value;
}
public
void
setKey(K key) {
this
.key = key; }
public
void
setValue(V value) {
this
.value = value; }
public
K getKey() {
return
key; }
public
V getValue() {
return
value; }
}
public
class
Gfg {
public
static
String largestAnagramGrp(String s)
{
Map<String, Pair<Integer, String> > unmap
=
new
HashMap<>();
StringTokenizer st =
new
StringTokenizer(s);
String word;
int
maxx =
0
;
String result =
""
;
while
(st.hasMoreTokens()) {
String temp = st.nextToken();
char
[] wordArray = temp.toCharArray();
Arrays.sort(wordArray);
word =
new
String(wordArray);
if
(!unmap.containsKey(word)) {
Pair<Integer, String> pair
=
new
Pair<>(
1
, temp);
unmap.put(word, pair);
}
else
{
Pair<Integer, String> pair
= unmap.get(word);
pair.setKey(pair.getKey() +
1
);
}
if
(unmap.get(word).getKey() > maxx) {
maxx = unmap.get(word).getKey();
result = unmap.get(word).getValue();
}
}
return
result;
}
public
static
void
main(String[] args)
{
String S
=
"cat is not a dog and sword has no words when government creates act so what is tac"
;
System.out.println(largestAnagramGrp(S));
}
}