For this problem our main task is to find the length of the longest pallindrome present at the end,leaving that all the starting elements needs to be added

For ex:abede

here: longest pallindrome at end is ede all the rest elements from the start (ab) needs to be added at last so ans is 2

```
public class Solution {
public int solve(String A) {
int i=0,j=A.length()-1,k=0,t=0;
while(i<=j)
{
if(A.charAt(i)!=A.charAt(j))
{
i++;j=A.length()-1;
}
else
{
if(j==A.length()-1)
k=i;
i++;
j--;
}
}
return k;
}
}
```