![](http://i1.daumcdn.net/thumb/C148x148.fwebp.q85/?fname=https://blog.kakaocdn.net/dn/bx8aVP/btqyM3DlScb/xeOy19UHCKt3vJ6EKZQdWK/img.png)
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..
![](http://i1.daumcdn.net/thumb/C148x148.fwebp.q85/?fname=https://blog.kakaocdn.net/dn/b2UEqS/btqyJRwHiPF/cAxlkRTWne7TP7h3iXmFE0/img.jpg)
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..
자바스크립트의 배열은 문자열, 숫자, 객체 등 어떤 타입의 값이라도 담을 수 있음. 배열안에 배열을 넣어 다차원으로 만드는 것도 물론 가능함. ex. [ 1, "2", {...}, [4] ] 이상한 나라의 배열?_? 1. 빵꾸난 배열이 생길 수 있음 var a = []; a[10] = "foo"; // [empty x 10, "foo"] 위처럼 배열 인덱스로 값을 넣어주면 값이 없는 공간들이 발생할 수 있음. 그렇다고해서 명시적으로 a[0] = undefined 를 한 것과는 같지 않다고 함.. 2. 배열 인덱스를 문자열로 표현한 10진수 숫자로 써도... 숫자처럼 인식함(엥?) var b = []; b["10"] = "bar"; //[ empty x 10, "bar"] 진짜 이상해.. 3. 인덱스에 키..
- Total
- Today
- Yesterday
- greedyAlgorithm
- 웹팩
- Algorithm
- 시분할시스템
- 컴퓨터공학
- 프로그래머스
- 리액트
- 자바스크립트
- React
- Array
- redux-saga
- 타입스크립트
- 우아한테크러닝
- Props
- OS
- 운영체제
- 알고리즘
- 멀티프로그래밍
- 배열
- 구간합
- Webpack
- 배치처리시스템
- sort
- js
- reduce()
- 1day1algorithm
- Typescript
- sort()
- 자료구조
- javascript
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |