티스토리 뷰

1Day 1Algorithm

[DAY 7] A Very Big Sum

walk_through_me 2019. 10. 7. 22:39

Calculate and print the sum of the elements in an array, keeping in mind that some of those integers may be quite large.

 

 

A Very Big Sum | HackerRank

Calculate the sum of the values in an array that might exceed the range of int values.

www.hackerrank.com

 

풀이

function aVeryBigSum(ar) {
    return ar.reduce((acc, cur) => acc + cur);
}

너모 쉬운 문제여따,, 주어진 Array 값들을 모두 합치는거라 간단하게 reduce 함수를 씀. 끝!

'1Day 1Algorithm' 카테고리의 다른 글

[DAY 9] Max Min  (0) 2019.10.09
[DAY 8] Greedy Florist  (0) 2019.10.08
[DAY 6] Recursion: Fibonacci Numbers  (0) 2019.10.06
[DAY 5] Flipping bits  (0) 2019.10.05
[DAY 4] Bitwise Operators  (0) 2019.10.04
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
글 보관함