Leetcode 533 Lonely Pixel II
来源:互联网 发布:php is numeric 漏洞 编辑:程序博客网 时间:2024/05/17 12:51
在上一个代码上改的,个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; }}
0 0
- Leetcode 533 Lonely Pixel II
- [Leetcode] 533. Lonely Pixel II 解题报告
- 533. Lonely Pixel II
- 531. Lonely Pixel I ----Leetcode
- [LeetCode]531. Lonely Pixel I
- [Leetcode] 531. Lonely Pixel I 解题报告
- 531. Lonely Pixel I
- lonely
- lonely
- Lonely lonely lonely...
- 532. K-diff Pairs in an Array\531. Lonely Pixel I
- pixel
- Pixel
- [Music]Lonely
- Lonely Christmas!
- 恩,lonely
- Lonely Low
- Mr.lonely
- PE框架——发送报文流程
- 2017年3月5日 周考3 解题报告
- 中游学院Swift语言视频教程swift培训视频
- xcode8.2 免证书手机调试详解
- PE框架简介
- Leetcode 533 Lonely Pixel II
- python 异常处理、assert应用、常见异常
- 2014传智播客ios第4期基础班+就业班
- sdutacm-数据结构实验之二叉树二:遍历二叉树
- Oracle自定义函数
- 从Paxos到Zookeeper分布式一致性原理与实践 -笔记
- 数组一些方法
- 3月题外:关于JS实现图片缩略图效果的一个小问题
- sdutacm-数据结构上机测试4.1:二叉树的遍历与应用1