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 함수를 씀. 끝!
Compare the Triplets | HackerRank Compare the elements in two triplets. www.hackerrank.com 풀이 function compareTriplets(a, b) { let result = [0, 0]; for(let i = 0; i b[i]) { result[0] += 1; } else if (a[i] < b[i]) { result[1] += 1; } } return result; } 1. 결과 값을 담을 result 라는 변수를 선언함. 2. for문을 돌면서 a와 b의 값을 비교하고, 값이 큰 사람에게 결과 값 1을 result에 더해줌 3. result를 리턴함 다른 사람의 풀이 function c..
John works at a clothing store. He has a large pile of socks that he must pair by color for sale. Given an array of integers representing the color of each sock, determine how many pairs of socks with matching colors there are. For example, there are n=7 socks with colors ar=[1,2,1,2,1,3,2]. There is one pair of color 1 and one of color 2. There are three odd socks left, one of each color. The n..
- Total
- Today
- Yesterday
- 프로그래머스
- 1day1algorithm
- 배치처리시스템
- 시분할시스템
- sort
- Webpack
- Algorithm
- 배열
- 타입스크립트
- 우아한테크러닝
- Array
- 구간합
- sort()
- greedyAlgorithm
- OS
- React
- 운영체제
- reduce()
- javascript
- Props
- 리액트
- 자바스크립트
- 컴퓨터공학
- 웹팩
- 알고리즘
- 멀티프로그래밍
- js
- 자료구조
- Typescript
- redux-saga
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |