Solution in JavaScript const arr = [1, 3, 2, 6, 1, 2]; const k = 3; const n = arr.length; function Divisible_Sum_Pairs(n, k, ar) { let num = 0; for(let i = 0; i < n; i++) { //condition 'i < j' 는 i보다 j가 index number로서 우선할 수 없다는 의미지 값이 커야한다는 의미가 아님. //문제 제대로 읽기! for(let j = (i + 1); j < n; j++){ if((ar[i] + ar[j]) % k === 0){ // 계산순서위한 () 잊지말것. ++num; } } } console.log(num); } Divisible_Sum_Pairs(..
Solution in JavaScript const scores = [10, 5, 20, 20, 4, 5, 2, 25, 1]; function breakingRecords(scores) { let [max, min] = [scores[0], scores[0]]; //중복배열로 선언 let [maxCount, minCount] = [0, 0]; for (let i = 1; i max) { //array로 넣어야지... max = scores[i]; maxCount++ } if (scores[i] < min) { min = scores[i]; minCount++ } } return [maxCount, minCount]; //두개 이상의 ..
Solution in JavaScript I const s = 7; const t = 10; const a = 4; const b = 12; const apples = [2, 3, -4]; const oranges = [3, -2, -4]; function countApplesAndOranges(s, t, a, b, apples, oranges) { let k = 0; let j = 0; let i; for (i = 0; i = s && a + apples[i] = s && b + oranges[i] value + a >= s && value + a value + b >= s && value + b
Solution in JavaScript const grades = [73, 67, 38, 33]; function gradingStudents(grade) { for (let i = 0; i = 38) { if (grade[i] % 5 === 3) { grade[i] += 2 } else if (grade[i] % 5 === 4) { grade[i] += 1 } } } return grade; } console.log(gradingStudents(grades)); //[ 75, 67, 40, 33 ] Reference https://www.hackerrank.com/challenges/grading/problem Grading Stude..
Solution in JavaScript const s = '07:05:45PM'; function TimeConversion(s) { // string을 바꿀 수 없으니 split을 사용해서 array로 바꿔준다. // AM과 PM도 삭제. '00:00:00AM' -> ['00', '00', '00'] //const arr = s.slice(0, 8).split(':'); const arr = s.split(':'); //indexOf(): 원하는 element의 index number return하고 원하는 index가 없으면 -1 return //PM 이 존재하면 최소 0 이니까 조건을 '> -1' 로 준다. //min 과 sec은 같고 시간 즉 arr[0]만 변화주면됨. arr[0] = (s.in..
- Total
- Today
- Yesterday
- hackerrank javascript
- 프로그래머스 알고리즘문제
- easy algorithm
- math.abs
- spring boot application
- substring()
- easy javascript algorithm
- hackerrank
- string class in java
- code refactoring
- rest parameter
- compareTo()
- repeat()
- algorithm
- 프로그래머스
- HackerRank Algorithm
- equals()
- 알고리즘
- math.max
- java
- HashMap
- 프로그래머스 알고리즘
- C++
- hackerrank javascript solution
- hackerrank solution
- Object type casting
- Collection Framework
- ... in Javascript
- javascript
- Javascript Algorithm
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |