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

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 solution (5)
Invert Binary Tree

Binary Tree(이진트리) 의 node와 그 node의 children을 invert 하는 문제. node뿐 아니라 그 밑에 속해있는 자식들까지 swipe해야하기때문에 recursive function(재귀함수)을 사용해야한다. Solution 1 var invertTree = function(root) { //재귀의 정지값->root가 있을때 까지. if(root){ swap(root); //swipe children invertTree(root.left); //subtree의 children에게도 같은 process적용을 위해 recursive invertTree(root.right); } return root; }; var swap = function(root){ let left = root...

Algorithms 2020. 11. 30. 22:51
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
Find Digits

Solution I in Javascript function solve(n) { //toString: number to string // 1012 //split: split("")는 string split into an array of substrings //하나하니의 element로 나누기 위해서 기준을 빈칸이없는 ''로 잡는다 // [1,0,1,2] //filter: 전체 element중 조건을 통과한 element로 new array 만든다 return n.toString().split('').filter(i => n % i === 0).length } console.log(solve(1012)); //3 Solution II in Javascript function solve(n) { let st..

Algorithms 2020. 9. 13. 11:30
Bon Appétit

Solution in JavaScript const arr = [3, 10, 2, 9]; const k = 1; const b = 12; function solve(bill, k, b) { bill[k] = 0; // 해당 index를 제외하고 시작. let sum = bill.reduce((x,y) => x + y); // reduce로 전부 sum let each = sum / 2; if(each === b){ console.log('Bon Appetit'); } else { console.log(b - each); } } solve(arr, k, b); //loop해서 k의 index를 제외하는 것 -> 해당 index에 0을 넣기.(이 생각을 내가 왜 못했을까!) Reference www.hack..

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

Blog is powered by Tistory / Designed by Tistory

티스토리툴바