Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solution(board)
- {
- var arr = [];
- let index = 0;
- let max = 0;
- for(let value of board){
- value.forEach((v,i)=>{
- if(v === 1){
- arr[i] = (arr[i])? arr[i]+1: 1;
- }
- })
- }
- arr.forEach((v)=>{
- if(max < v){
- max = v;
- }
- })
- arr.sort((a,b)=>a-b);
- for(let i = max; i > 0; i--){
- for(let value of arr){
- if(value >= i){
- index++;
- }
- }
- if(i === index){
- return i*i;
- }
- index = 0;
- }
- }
Add Comment
Please, Sign In to add comment