A group of friends wants to buy a bouquet of flowers. The florist wants to maximize his number of new customers and the money he makes. To do this, he decides he'll multiply the price of each flower by the number of that customer's previously purchased flowers plus 1. The first flower will be original price, (0 + 1) * original price, the next will be (1 + 1) * original price and so on. Given the..
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 함수를 씀. 끝!
The Fibonacci Sequence The Fibonacci sequence appears in nature all around us, in the arrangement of seeds in a sunflower and the spiral of a nautilus for example. The Fibonacci sequence begins with fibonacci(0) = 0 and fibonacci(1) = 1 as its first and second terms. After these first two elements, each subsequent element is equal to the sum of the previous two elements. Programmatically: fibona..
Day 6: Bitwise Operators | HackerRank Apply everything we've learned in this bitwise AND challenge. www.hackerrank.com We define S to be a sequence of distinct sequential integers from 1 to n; in other words, S = {1, 2, 3,..., n}. We want to know the maximum bitwise AND value of any two integers, a and b (where a < b), in sequence S that is also less than a given integer, k. Complete the functio..
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..
자바스크립트의 배열은 문자열, 숫자, 객체 등 어떤 타입의 값이라도 담을 수 있음. 배열안에 배열을 넣어 다차원으로 만드는 것도 물론 가능함. 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. 인덱스에 키..
자바스크립트 내장 타입 7가지 null undefined boolean number string object symbol {} === {} //false {} == {} //false null === undefined //false 42 === “42” //false null == undefined //true 42 == “42” //true true == 1 //true false == 0 //true 타입은 typeof 연산자로 확인할 수 있음 typeof null //object typeof undefined //undefined typeof Symbol() //symbol typeof Symbol //function *typeof가 반환하는 function은 object의 하위 타입임(callab..
- Total
- Today
- Yesterday
- 배치처리시스템
- reduce()
- 리액트
- 알고리즘
- Array
- 웹팩
- 운영체제
- 배열
- 멀티프로그래밍
- sort
- 자바스크립트
- sort()
- 1day1algorithm
- Typescript
- 시분할시스템
- js
- 타입스크립트
- 컴퓨터공학
- greedyAlgorithm
- Webpack
- OS
- Props
- 프로그래머스
- 자료구조
- 구간합
- Algorithm
- React
- redux-saga
- 우아한테크러닝
- 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 |