title: How to write return who letters you should remove to make string palindrome?
body: <p>Like in question, exercise if it is possible to create a palindromic string of minimum length 3 characters by removing 1 or 2 characters. For example string &quot;abjchba&quot;, we can remove letters &quot;jc&quot; and will get palindromic, in this case program should return removed letters so &quot;jc&quot;. I know that we can mke palindromic by removing also &quot;ch&quot; but in exercise is that we should remove characters that appear earlier in string. Program should always attempt to create the longest palindromic substring. I wrote methods to reverse String and method to check that string is palindromic:</p>
  <pre><code>private static String reverse(String string) {
          return new StringBuilder(string).reverse().toString();
      }
  
  private static boolean isPalin(String string) {
          return string.equals(reverse(string));
      }
  </code></pre>
  <p>I also made method to create Palindromic to return symbols we should remove to make palindromic, but beacuse i'm working on sb 'temp' I got exception . Have anyone idea how to fix it and finish exercise?</p>
  <pre><code>private static String createPalindrome(String str) {
          StringBuilder result = new StringBuilder();
          StringBuilder temp = new StringBuilder(str);
          for (int i = 0; i &lt; str.length(); i++) {
              if (str.charAt(i) == str.charAt(str.length() - 1 - i)){
                  continue;
              }else {
                  result.append(str.charAt(i));
                  temp.deleteCharAt(i);
                  if (isPalin(temp.toString())){
                      return result.toString();
                  }
              }
          }
          return &quot;not possible&quot;;
      }
  </code></pre>