Comments

Mauritius Rupee Oklahoma8 months ago

const solve = (intArr) => {
  for (let arr of intArr) {
    if (arr.every(int => int === 1)) return true;
  }
  let result;
  for (let i = 0; i < intArr[0].length; i++) {
    result = [];
    for (let j = 0; j < intArr.length; j++) {
      result.push(intArr[j][i]);
    }
    if (result.every(int => int === 1)) return true;
  }
  return false
};

Abdelhamid Ismail9 months ago

const solve = (intArr) => {
  const rowsResult = intArr.some((innerArr) => innerArr.every((e) => e === 1));
  if (rowsResult) {
    return true;
  }

  for (let col = 0; col < intArr.length; col++) {
    let result = true;

    for (let row = 0; row < intArr.length; row++) {
      if (intArr[row][col] !== 1) {
        result = false;
        break;
      }
    }

    if (result) {
      return true;
    }
  }
  return false;
};