accepted ruby solution


  • 0
    B
    m = picture.size
        n = picture[0].size
        row = Array.new(m,0)
        col = Array.new(n,0)
        (0...m).each do |i|
            (0...n).each do |j|
                if picture[i][j] == 'B'
                    row[i] += 1
                    col[j] += 1
                end
            end
        end
        res = 0
        (0...row.size).each do |i|
            (0...col.size).each do |j|
                if row[i] == 1 && col[j] == 1 && picture[i][j] == 'B'
                    res += 1
                end
            end
        end
        return res
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.