카펫

2020.08.28

const solution = (brown, yellow) => {
  const total = brown + yellow;
  let col = Math.floor(Math.sqrt(total));
  let row;
  while (col > 2) {
    if (total % col == 0) {
      row = total / col;
      if ((row + col) * 2 - 4 == brown) {
        return [row, col];
      }
    }
    col--;
  }
};
  • 쉬운 문제였네...

0개의 댓글