title: Fails for larger test cases : Minimum Characters required to be added to make a String Palindromic
body: <p>Question: <a href="https://www.interviewbit.com/problems/minimum-characters-required-to-make-a-string-palindromic/" rel="nofollow noreferrer">Minimum Characters required to make a String Palindromic</a></p>
  
  <p>Issue: Code works fine for test cases, but while submitting it says, code is failing for <strong>larger test cases</strong>. Not sure why it is not working. </p>
  
  <p>Approach: Splitting string from mid to 0th index by keeping ith char at center (Ex: String=ABBA, for i=1: A B BA) or ith char at left (String=ABBA, for i=1: AB BA) and checking if entire left part is palindrome with portion of right part, if true remaining portion of right part is to be added to left part, which is our answer.</p>
  
  <p>Answer: if input is palindrome from 0th to kth index, return length-1-k</p>
  
  <p><strong>Update</strong></p>
  
  <p>The problem is how many minimum chars are required to be added to left of string to make it palindrome. More details in the question link which i have provided at top.</p>
  
  <p>Example: String A = "mmtatbdzqsoemuvnpppsu";
           answer is 19
           Reason: index 0 and index 1 are palindrome. from index 2 to 20 is not. so if we add chars from 2 to 20 to left of string in reverse order, entire string will be palindrome.</p>
  
  <p>Example2: String A = "mnnmpq"
           if we add pq to left of string in reverse order entire string will be palindrome. </p>
  
  <p>All my test cases what I can think is passing. But code is not submitting in the portal saying it may fail for larger outputs. It is a leetcode like portal. I can't think of any larger test case for which my code is failing.</p>
  
  <p>Please throw me some light.</p>
  
  <pre><code>public class Solution {
      public int solve(String A) {
          if(A==null || A.length()==0) return 0;
          int mid=(A.length()-1)/2;
          for(int i=mid; i&gt;-1; i--) {
              if(i&gt;0 &amp;&amp; checkCenter(A,i)) return A.length()-1-2*i;
              if((i&lt;mid || A.length()%2==0) &amp;&amp; checkLeft(A,i)) return A.length()-1-(2*i+1);
          }
        return A.length()-1;
      }
      public boolean checkCenter(String A, int pos) {
          int start=pos-1;
          int end=pos+1;
          while(start&gt;-1) {
              if(A.charAt(start)!=A.charAt(end)) return false;
              start--;
              end++;
          }
        return true;
      }
      public boolean checkLeft(String A, int pos) {
          int start=pos;
          int end=pos+1;
          while(start&gt;-1) {
              if(A.charAt(start)!=A.charAt(end)) return false;
              start--;
              end++;
          }
        return true;
      }
  }
  </code></pre>