๐Ÿ’Ž

ARR PS - maximum sum of two numbers

notion image
ย 
notion image
ย 

ํ’€์–ด๋ณด๊ธฐ

sort๋กœ ๋‚ด๋ฆผ์ฐจ์ˆœ ์ •๋ ฌ์„ ํ•œ๋‹ค์Œ ๋งจ์•ž์—์„œ 2๊ฐœ๋ฅผ ๋ฝ‘์•„ ๋ฐฐ์—ด์„ ๋งŒ๋“ค์—ˆ๋‹ค. ๊ฐ€์žฅ ํฐ ์ˆซ์ž ๋‘๊ฐœ๋ฅผ ๋”ํ•ด์•ผ ํ•ฉ์ด ๊ฐ€์žฅ ์ปค์งˆ ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
ย 
function answer(nums) {
    let result = [];
    nums.sort((a, b) => b - a);
    console.log([nums[0], nums[1]]);

    return;
}
ย 
ย