Can Anyone tell me why is it giving me Wrong Answer


#1

public class Solution {
public int solve(ArrayList A) {
char first_color=A.get(0).charAt(0);
int base=0;
char second_color=‘a’;
for(int i=A.size()-1;i>=1;i–){
second_color=A.get(i).charAt(0);
if(second_color!=first_color){
base=i+1;
break;
}
}
if(base==0){
return 0;
}
int height=0;
char third_color=‘a’;
for(int i=A.get(0).length()-1;i>=1;i–){
for(int j=0;j<A.size();j++){
third_color=A.get(j).charAt(i);
if(third_color!=first_color && third_color!=second_color){
height=i+1;
break;
}
}
if(height>0){
break;
}
}
if(height==0){
return 0;
}
return (base*height)/2;
}
}


#2

If you guys have any doubt about testcases or soln check this out…it will surely help you guys…