title: How to find biggest anagram in given paragraph in Java
body: <p>I am trying to find the biggest anagram in given paragraph. Assume a string is provided to me containing words. Now I want to find all the anagrams and among all anagrams I want to return a list of all the biggest anagrams.</p>
  
  <p>For example,</p>
  
  <pre><code>String s = "Hello jjkkllmm how are you. See you at lljjmmkk tomorrow with kkjjmmll. ootty tyoto"
  </code></pre>
  
  <p>Here the words <em>jjkkllmm</em>, <em>lljjmmkk</em>, <em>kkjjmmll</em>, *ootty, and <em>tyoto</em> are anagrams, among them the words <em>jjkkllmm</em>, <em>lljjmmkk</em>, and <em>kkjjmmll</em> are biggest and equal in size, so my method should return all biggest and equally sized anagram words.</p>
  
  <p>I tried the below code from my side, but I don't know if it is the perfect solution or if it can be improved.</p>
  
  <pre><code>public static Set&lt;String&gt; findAllAnagram(String words)
  {
      Map&lt;String,String&gt; tempMap = new HashMap&lt;String,String&gt;();
      Set&lt;String&gt; allAnagrams = new LinkedHashSet&lt;String&gt;();
      String[] wordArr = words.split(" ");
  
      for (String string : wordArr)
      {
          if(tempMap.containsKey(sort(string)))
          {
              allAnagrams.add(tempMap.get(sort(string)));
              allAnagrams.add(string);
          }
          else
          {
              tempMap.put(sort(string), string);
          }
      }
      return allAnagrams;
  }
  
  public static String findBiggestAnagram(String word)
  {
      Set&lt;String&gt; allAnagrams =findAllAnagram(word);
      int biggestAnnagramCount = 0;
      String biggestAnnaGramWord = "";
      for (String string : allAnagrams)
      {
          if(biggestAnnagramCount&lt;string.length())
          {
              biggestAnnaGramWord = string;
              biggestAnnagramCount=string.length();
          }
      }
      return biggestAnnaGramWord;
  }
  </code></pre>