国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Leetcode 533 Lonely Pixel II

2019-11-06 06:48:15
字體:
來源:轉載
供稿:網友
在上一個代碼上改的,個rule2看了半天沒看懂。。rule2的意思是,若一個b其所在的行列都等于N,那么其所有列都與本行一毛一樣,那么count++
public class Solution {    public int findBlackPixel(char[][] picture, int N) {        int count=0;        HashMap<Integer,Integer> row =new HashMap<>();        HashMap<Integer,LinkedList<Integer>> column =new HashMap<>();        HashMap<Integer,String> table =new HashMap<>();        for(int i=0;i<picture.length;i++){            for(int j=0;j<picture[0].length;j++){                if(picture[i][j]=='B'){                    if(row.containsKey(i)){                        row.put(i,row.get(i)+1);                    }else{                        row.put(i,1);                    }                    if(column.containsKey(j)){                        column.get(j).add(i);                        column.put(j,column.get(j));                    }else{                        LinkedList<Integer> list=new LinkedList<>();                        list.add(i);                        column.put(j,list);                     }                }            }            table.put(i,String.valueOf(picture[i]));        }        for(int i=0;i<picture.length;i++){            for(int j=0;j<picture[0].length;j++){                    if(picture[i][j]=='B'&&(row.containsKey(i)&&row.get(i)==N&&column.containsKey(j)&&column.get(j).size()==N)){                    LinkedList<Integer> list=column.get(j);                    boolean mark=true;                    for(int k=0;k<list.size();k++){                        if(!table.get(i).equals(table.get(list.get(k)))){                            mark=false;                        }                    }                    if(mark) count++;                }            }        }        return count;    }}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 五指山市| 南乐县| 女性| 兴文县| 莎车县| 邢台市| 桃园市| 湄潭县| 怀仁县| 昌宁县| 镇平县| 黎城县| 沭阳县| 宜都市| 疏勒县| 玉溪市| 景泰县| 台东市| 阿瓦提县| 清水河县| 金山区| 辉南县| 临江市| 安顺市| 龙山县| 方山县| 来安县| 琼海市| 迁安市| 图木舒克市| 巴塘县| 辽中县| 久治县| 石家庄市| 云梦县| 屯昌县| 礼泉县| 五原县| 张家川| 上犹县| 余庆县|