본문 바로가기

전체 글47

이진트리) Maximum Depth of Binary Tree [js] Maximum Depth of Binary Tree - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 //이런식으로 재귀 코드를 작성하고 생각하는 것이 더 쉽기 때문에 핸들러 함수를 사용 var maxDepth = function(root) { //깊이의 정의 때문에 숫자/깊이 값 1에서 시작 return maxDepthHandler(root,1) }.. 2021. 8. 27.
이진트리(binary tree), 이진트리 순회방법 이진트리 : 부모 하나에 자식이 둘 딸린 구조 1.1 이진트리 종류 Binary Tree(기본) 다른 조건 없이 자식노드가 2개씩만 붙어 있음됌 Binary Search Tree 안에 데이터가 왼쪽 노드와 그 이하의 자식 도드들은 현재 노드 보다 작아야 함 오른쪽 노드와 그 이하 자식 노드들은 현재노드(8) 보다 커야함 만약 8보다 작은수를 찾고싶으면 왼쪽, 반대로 8보다 큰 수를 찾고싶으면 오른쪽으로 가면 된다. Balance UnBalance Complete Bianry Tree(완전이진트) 모든 노드들이 왼쪽부터 채워져 있고 마지막 레벨은 왼쪽부터 채워져 있다 Full Bianry Tree 자식노드가 아예 없거나 2개로 구성된 Tree Perfect Bianry Tree 모든 노드가 2개의 자식노드.. 2021. 8. 25.
프로그래머스 모의고사 javascript 문제링크 https://programmers.co.kr/learn/courses/30/lessons/42840 코딩테스트 연습 - 모의고사 수포자는 수학을 포기한 사람의 준말입니다. 수포자 삼인방은 모의고사에 수학 문제를 전부 찍으려 합니다. 수포자는 1번 문제부터 마지막 문제까지 다음과 같이 찍습니다. 1번 수포자가 찍는 programmers.co.kr 코드 function solution(answers) { let answer = []; let supo = [ [1, 2, 3, 4, 5], [2, 1, 2, 3, 2, 4, 2, 5], [3, 3, 1, 1, 2, 2, 4, 4, 5, 5], ]; let score = []; for (let i = 0; i < supo.length; i++) { le.. 2021. 8. 21.
프로그래머스) K번째 수 Javascript https://programmers.co.kr/learn/courses/30/lessons/42748 코딩테스트 연습 - K번째수 [1, 5, 2, 6, 3, 7, 4] [[2, 5, 3], [4, 4, 1], [1, 7, 3]] [5, 6, 3] programmers.co.kr function solution(array, commands) { const answer = []; commands.forEach(command => { const arrayCommand = array.slice(command[0]-1, command[1]); arrayCommand.sort((a,b) => a - b); answer.push(arrayCommand[command[2]-1]); }) return answer; }.. 2021. 8. 20.