/*
* #dCoding
/
import java.util.;
class ZCO15001
{
int na[],dp[],n;
void input()
{
Scanner s=new Scanner(System.in);
n=s.nextInt();
na=new int[n];
dp=new int[n+1];
for(int i=0;i<n;i++){
na[i]=s.nextInt();
}
}
boolean checkPalin(int i,int j)
{
boolean res=true;
for(int k=i;k<=(i+j)/2;k++){
if(na[k]!=na[j-(k-i)]){
res=false;
break;
}
}
return res;
}
void solve()
{
dp[0]=0;
for(int i=1;i<=n;i++)
dp[i]=i;
byte flag=0;
for(int i=0;i<n;i++){
for(int j=0;j<i;j++){
if(checkPalin(j,i)){
dp[i+1]=Math.min(dp[i+1],dp[j]+1);
//System.out.println("dp["+(i+1)+"]="+dp[i+1]);
flag=1;
//break;
}
}
if(flag==0){
dp[i+1]=dp[i]+1;
}
else{
flag=0;
}
//System.out.println("dp["+(i+1)+"]="+dp[i+1]);
}
}
void display()
{
System.out.println(dp[n]);
}
public static void main(String[] args)
{
ZCO15001 Z=new ZCO15001();
Z.input();
Z.solve();
Z.display();
}
}
Can someone help me to find the error in my code? It passes only 3 out of the seven test cases and receives WA in the others!