- 44.4%
https://leetcode.com/contest/leetcode-weekly-contest-22/problems/lonely-pixel-i/
Given a picture consisting of black and white pixels, find the number of black lonely pixels.
The picture is represented by a 2D char array consisting of ‘B’ and ‘W’, which means black and white pixels respectively.
A black lonely pixel is character ‘B’ that located at a specific position where the same row and same column don’t have any other black pixels.
1 | Example: |
Note:
- The range of width and height of the input 2D array is [1,500].
cpp
my code:
与第200道,小岛的题目很类似,可以考虑参考。但是有不一样,这里建立两个数组,保证横纵坐标都是1,且此处为‘B’就是要找的点,计数。
1 | class Solution { |