Viral Advertising
Solution in Javascript const n = 3; function viralAdvertising(n) { let k = 5; let j = 0; let sum = 0; for(let i = 0; i < n; i++){ j = Math.floor(k/2); k = j * 3; sum+=j; } console.log(sum); } viralAdvertising(n); *Use Math.floor() to get quotient. Reference www.hackerrank.com/challenges/strange-advertising/problem
Algorithms
2020. 10. 22. 19:31
Angry Professor
Solution in Javascript I const k = 3; const a = [-1, -3, 4, 2]; function angryProfessor(k, a) { const p = a.filter(v => v < 1).length < k ? 'YES' : 'NO' return p; } angryProfessor(k, a); 1. To filter elements which are less than 1, use filter() 2. length() is used to get the number of the elements. for loop 와 if 를 사용하는 것보다 내장 함수들을 사용하자. Solution in Javascript II const k = 4; const a = [-1, -3, -..
Algorithms
2020. 10. 19. 18:49
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- easy algorithm
- Javascript Algorithm
- 프로그래머스
- hackerrank solution
- substring()
- C++
- math.max
- java
- easy javascript algorithm
- HashMap
- hackerrank javascript solution
- hackerrank javascript
- javascript
- spring boot application
- 프로그래머스 알고리즘
- equals()
- rest parameter
- 알고리즘
- 프로그래머스 알고리즘문제
- Object type casting
- repeat()
- algorithm
- hackerrank
- compareTo()
- string class in java
- math.abs
- HackerRank Algorithm
- code refactoring
- ... in Javascript
- Collection Framework
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함