Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 38a2156

Browse files
Add 최소직사각형.js
1 parent f7b30ee commit 38a2156

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎level-1/최소직사각형.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,19 @@ function solution(sizes) {
88
const maxHeight = Math.max(...sizes.map(card => card[1]))
99
answer = maxWidth * maxHeight
1010
return answer;
11+
}
12+
13+
// 정답 2 - prove-ability
14+
function solution(sizes) {
15+
16+
// 가로, 세로 중 큰 값을 가로 길이로 변경(스압)
17+
sizes.forEach(([width, height], index) => {
18+
if(sizes[index][0] < sizes[index][1]) [sizes[index][0], sizes[index][1]] = [sizes[index][1], sizes[index][0]]
19+
})
20+
21+
// 가로, 세로 각각 큰 값 추출
22+
const widthMax = Math.max(...sizes.map(v => v[0]));
23+
const widthHeight = Math.max(...sizes.map(v => v[1]));
24+
25+
return widthMax * widthHeight;
1126
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /