✨ 문제 Counting BitsGiven an integer n, return an array ans of length n + 1 such that for each i (0 ), ans[i] is the number of 1's in the binary representation of i. https://leetcode.com/problems/counting-bits/description/ ✨ 개념동적 프로그래밍 Dynamic Programming- 복잡한 문제를 작은 문제로 분해하여 해결하는 알고리즘 기법.- 동적 프로그래밍을 적용하기 위해서는 다음 2가지 조건이 필요하다.최적 부분 구조 : 전체 문제의 최적해를 부분 문제의 최적해로부터 찾을 수 있어야함.중복되는 부분 문제 : 부분 문제가 여러..
항해99
✨ 문제 Split a String in Balanced StringsBalanced strings are those that have an equal quantity of 'L' and 'R' characters.Given a balanced string s, split it into some number of substrings such that:Each substring is balancedReturn the maximum number of balanced strings you can obtain. https://leetcode.com/problems/split-a-string-in-balanced-strings/description/ ✨ 개념탐욕법 Greedy Algorithm- 현재 상황에서..
✨ 문제 체육복점심시간에 도둑이 들어, 일부 학생이 체육복을 도난당했습니다. 다행히 여벌 체육복이 있는 학생이 이들에게 체육복을 빌려주려 합니다. 학생들의 번호는 체격 순으로 매겨져 있어, 바로 앞번호의 학생이나 바로 뒷번호의 학생에게만 체육복을 빌려줄 수 있습니다. 예를 들어, 4번 학생은 3번 학생이나 5번 학생에게만 체육복을 빌려줄 수 있습니다. 체육복이 없으면 수업을 들을 수 없기 때문에 체육복을 적절히 빌려 최대한 많은 학생이 체육수업을 들어야 합니다. 전체 학생의 수 n, 체육복을 도난당한 학생들의 번호가 담긴 배열 lost, 여벌의 체육복을 가져온 학생들의 번호가 담긴 배열 reserve가 매개변수로 주어질 때, 체육수업을 들을 수 있는 학생의 최댓값을 return 하도록 solution ..
✨ 문제 Maximum Depth of Binary TreeGiven the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. https://leetcode.com/problems/maximum-depth-of-binary-tree/description/ ✨ 개념이진 트리- 분할 정복 탐색 알고리즘으로 빠른 속도로 탐색 가능- 모든 노드가 2개의 서브 트리를 갖는 트리. 서브트리는 공집합일 수 있음.- 모든 노드가 최대 2개의 자식 노드가..
✨ 문제 Invert Binary TreeGiven the root of a binary tree, invert the tree, and return its root. https://leetcode.com/problems/invert-binary-tree/description/ ✨ 개념이진 트리- 분할 정복 탐색 알고리즘으로 빠른 속도로 탐색 가능- 모든 노드가 2개의 서브 트리를 갖는 트리. 서브트리는 공집합일 수 있음.- 모든 노드가 최대 2개의 자식 노드가 존재할 수 있음.- 모든 노드의 차수가 2 이하.- 이진 트리에는 서브 트리간 순서가 존재하며 왼쪽 트리와 오른쪽 트리가 구별됨. ✨ 최종코드/** * Definition for a binary tree node. * public clas..
✨ 문제 Evaluate Boolean Binary TreeYou are given the root of a full binary tree with the following properties:Leaf nodes have either the value 0 or 1, where 0 represents False and 1 represents True.Non-leaf nodes have either the value 2 or 3, where 2 represents the boolean OR and 3 represents the boolean AND.The evaluation of a node is as follows: The evaluation of a node is as follows: If the nod..
✨ 문제 Find a Corresponding Node of a Binary Tree in a Clone of That TreeGiven two binary trees original and cloned and given a reference to a node target in the original tree.The cloned tree is a copy of the original tree.Return a reference to the same node in the cloned tree.Note that you are not allowed to change any of the two trees or the target node and the answer must be a reference to a no..
✨ 문제 Range Sum of BSTGiven the root node of a binary search tree and two integers low and high, return the sum of values of all nodes with a value in the inclusive range [low, high]. https://leetcode.com/problems/range-sum-of-bst/description/ ✨ 개념이진 탐색 트리 Binary Search Tree- 이진 트리의 특수한 형태로 정렬된 구조를 갖고 있음.- 왼쪽 서브트리에 있는 모든 노드의 값은 해당 노드의 값보다 작으며, 마찬가지로 오른쪽 서브트리에 있는 모든 노드의 값은 해당 노드의 값보다 크다.- 왼쪽 서브트..
✨ 문제 모의고사 array의 2번째부터 5번쨰까지 자르면 [5, 2, 6, 3]입니다.1에서 나온 배열을 정렬하면 [2, 3, 5, 6]입니다.2에서 나온 배열의 3번째 숫자는 5입니다.배열 array, [i, j, k]를 원소로 가진 2차원 배열 commands가 매개변수로 주어질 때, commands의 모든 원소에 대해 앞서 설명한 연산을 적용했을 때 나온 결과를 배열에 담아 return 하도록 solution 함수를 작성해주세요. https://school.programmers.co.kr/learn/courses/30/lessons/42748 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받..
✨ 문제 최소직사각형명함 지갑을 만드는 회사에서 지갑의 크기를 정하려고 합니다. 다양한 모양의 크기와 명함들을 모두 수납할 수 있으면서, 작아서 들고 다니기 편한 지갑을 만들어야 합니다. 이러한 요건을 만족하는 지갑을 만들기 위해 디자인팀은 모든 명함의 가로 길이와 세로 길이를 조사했습니다.아래 표는 4가지 명함의 가로 길이와 세로 길이를 나타냅니다.명함 번호가로 길이세로 길이16050230703603048040 가장 긴 가로 길이와 세로 길이가 각각 80, 70이기 때문에 80(가로) * 70(세로) 크기의 지갑을 만들면 모든 명함들을 수납할 수 있습니다. 하지만 2번 명함을 가로로 눕혀 수납한다면 80(가로) * 50(세로) 크기의 지갑으로 모든 명함들을 수납할 수 있습니다. 이때의 지갑 크기는 40..