public class Solution {
public int findLonelyPixel(char[][] picture) {
if (picture == null || picture.length < 1 || picture[0].length < 1) return 0;
int row = picture.length;
int col = picture[0].length;
int[] countR = new int[row];
int[] countC = new int[col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
if (picture[i][j] == 'B') {
countR[i]++;
countC[j]++;
}
}
}
int res = 0;
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
if (picture[i][j] == 'B' && countR[i] == 1 && countC[j] == 1) {
res++;
}
}
}
return res;
}
}