본문 바로가기 메뉴 바로가기

Studying programming

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

Studying programming

검색하기 폼
  • Jimin's Programming (194)
    • Algorithms (54)
    • JavaScript (16)
    • Vue.js (3)
    • Node.js (3)
    • React.js (7)
    • React Native (0)
    • Spring Boot (13)
    • JAVA (58)
    • C++ (17)
    • Programming (19)
    • Computer basics (4)
  • 방명록

hackerrank (16)
Cut the sticks

간단하게는 minimum value 로 each index를 subtract할 수 있는 갯수를 구하는 문제. Solution 1 in Javascript const arr = [5, 3, 2, 2, 2, 8] function cutTheSticks(arr) { //sort the array let sorted = arr.sort(); //set index[0] to a min let min = sorted[0]; console.log(sorted.length); for (let i = 0; i min) { min = sorted[i]; //change min to next shortest min console.log(sorted.le..

Algorithms 2020. 12. 18. 17:39
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
Beautiful Days at the Movies

Solution in Javascript const i = 20; const j = 23; const k = 6; function beautifulDays(i, j, k) { let beautifulDay = 0; while(i

Algorithms 2020. 10. 18. 18:41
Migratory Birds

The solution in Javascript I (Failed in HackerRank) sort 를 이용. 순서대로 정렬해준 후에 동일한 값의 (last index - first index) + 1 (0부터 시작하니까) 해외 블로그 접근이 좋긴했지만 결과적으로 HackerRank에서는 fail. const arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 3, 4, 1] function migratoryBirds(arr) { let bird = 1; let max = bird; //bird 의 시작이 1이라는 것은 at least one bird id는 존재한다는 의미. 나중에 더 큰 값이오면 대체. let result = 0; arr.sort(); //1,1,1,2,2,3,3,3,4,4..

Algorithms 2020. 10. 1. 23:50
Utopian Tree

Solution in JavaScript const n = 5; function utopianTree(n) { let cycle = 1; let height = 1; while (cycle

Algorithms 2020. 10. 1. 21:16
The Hurdle Race

Solution in Javascript const k = 4; const height = [1, 6, 3, 5, 2]; function hurdleRace(k, height) { const max = Math.max(...height); if ((max - k) The Hurdle Race | HackerRank Determine the maximum value in an array less a value, limit >= 0. www.hackerrank.com

Algorithms 2020. 9. 25. 21:59
이전 1 2 3 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
  • hackerrank javascript solution
  • code refactoring
  • 프로그래머스 알고리즘문제
  • math.max
  • spring boot application
  • Collection Framework
  • substring()
  • equals()
  • repeat()
  • easy javascript algorithm
  • 프로그래머스 알고리즘
  • ... in Javascript
  • C++
  • hackerrank
  • HackerRank Algorithm
  • HashMap
  • 프로그래머스
  • hackerrank solution
  • java
  • easy algorithm
  • javascript
  • string class in java
  • math.abs
  • 알고리즘
  • compareTo()
  • algorithm
  • Object type casting
  • rest parameter
  • hackerrank javascript
  • Javascript Algorithm
more
«   2025/11   »
일 월 화 수 목 금 토
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 29
30
글 보관함

Blog is powered by Tistory / Designed by Tistory

티스토리툴바