title: Longest String With Chars Palindrome
body: <p>Problem description from school assignment
  Longest String With Palindrome</p>
  
  <p>I'm getting complexity O(N^2). How can I achieve O(N*log(N))**</p>
  
  <p><strong>My code</strong></p>
  
  <pre><code>int maxL = 0;
      for (int i = 0; i &lt; S.length(); i++) {
          String currentString = String.valueOf(S.charAt(i));
          for (int j = i + 1; j &lt; S.length(); j = j + 1) {
              String jStr = String.valueOf(S.charAt(j));
              if (currentString.contains(jStr)) {
                  currentString = currentString.replace(jStr, "");
                  int len = j - i + 1;
                  if (currentString.length() == 0 &amp;&amp; maxL &lt; len) {
                      maxL = len;
                  }
              } else {
                  currentString = currentString + jStr;
              }
          }
      }
      return maxL;
  </code></pre>