최대 1 분 소요

part31. 바탕화면 정리

js ver 1.0

function solution(wallpaper) {

            // wallpaper.reduce((acc, [...row], i) => {
    const {x, y} = wallpaper.reduce((acc, row, i) => {

        // row.forEach((el, j) => {
        row.split('').forEach((el, j) => {
            if (el == '#') {
                acc.x.push(i);
                acc.y.push(j);
            }
        })

        return acc;
    }, {x: [], y: []})

    return [Math.min(...x), Math.min(...y), Math.max(...x) + 1, Math.max(...y) + 1];
}

실행결과_js ver 1.0


업데이트: