본문 바로가기

STUDY ALONE400

[D2] SWEA - 1859. 백만 장자 프로젝트 : Java SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com  문제 25년 간의 수행 끝에 원재는 미래를 보는 능력을 갖게 되었다. 이 능력으로 원재는 사재기를 하려고 한다.다만 당국의 감시가 심해 한 번에 많은 양을 사재기 할 수 없다.다음과 같은 조건 하에서 사재기를 하여 최대한의 이득을 얻도록 도와주자.    1. 원재는 연속된 N일 동안의 물건의 매매가를 예측하여 알고 있다.    2. 당국의 감시망에 걸리지 않기 위해 하루에 최대 1만큼 구입할 수 있다.    3. 판매는 얼마든지 할 수 있다.예를 들어 3일 동안의 매매가가 1, 2, 3 이라면 처음 두 날에 원료를 구매하여 마지막 날에 팔면 3의 이익을 얻을 수 있.. 2024. 10. 25.
[Easy] LeetCode - no.530 Minimum Absolute Difference in BST : Java https://leetcode.com/problems/minimum-absolute-difference-in-bst/description/?envType=study-plan-v2&envId=top-interview-150  문제이진 탐색 트리(BST)의 root가 주어졌을 때, 노드들 사이의 최소 차이를 반환할 것 Example 1    Input: root = [4,2,6,1,3]Output: 1       풀이1 public int getMinimumDifference(TreeNode root) { List values = new ArrayList(); Queue queue = new LinkedList(); queue.add(root); whi.. 2024. 10. 25.
[Easy] LeetCode - no.637 Average of Levels in Binary Tree : Java https://leetcode.com/problems/average-of-levels-in-binary-tree/?envType=study-plan-v2&envId=top-interview-150  문제이진 트리의 root가 주어졌을 때, 각 레벨별 평균을 구하여 반환할 것 Example 1  Input: root = [3,9,20,null,null,15,7]Output: [3.00000,14.50000,11.00000]Explanation: The average value of nodes on level 0 is 3, on level 1 is 14.5, and on level 2 is 11.Hence return [3, 14.5, 11].       풀이참고 [LeetCode] 637. Average .. 2024. 10. 25.
[Easy] LeetCode - no.222 Count Complete Tree Nodes : Java https://leetcode.com/problems/count-complete-tree-nodes/?envType=study-plan-v2&envId=top-interview-150  문제완전 이진 트리의 root가 주어졌을 때, 이 트리의 노드의 개수를 반환할 것 Example 1   Input: root = [1,2,3,4,5,6]Output: 6      풀이 public int countNodes(TreeNode root) { if (root == null) { return 0; } return countNodes(root.left) + countNodes(root.right) + 1; }root가 null이라면 리프 노드를 넘.. 2024. 10. 24.
[Easy] LeetCode - no.112 Path Sum : Java https://leetcode.com/problems/path-sum/description/?envType=study-plan-v2&envId=top-interview-150  문제이진 트리의 root와 정수 targetSum이 주어졌을 때, 트리의 루트로부터 리프까지의 합이 targetSum과 일치하는지 여부를 판단할 것 Example 1  Input: root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum = 22Output: trueExplanation: The root-to-leaf path with the target sum is shown.      풀이참고 LeetCode 112(Path Sum, java)0. 문제 https://leetc.. 2024. 10. 24.
[우테코] 7기 프리코스 1주차 회고 - 2탄 1주차 회고 1탄에서는 미션을 진행하면서 고민한 점, 배운 점, 느낀 점 등을 정리했다면, 2탄에서는 코드 리뷰를 받고 리팩토링한 부분들에 대해 정리해보려 한다!   Controller가 '다른 객체를 생성하는 책임'을 가져야 할까?AppConfig의 역할에 대해 정확히 알지 못했기 때문에 놓친 부분이다. 기존코드public class CalculatorController { private final DelimiterCalculator delimiterCalculator; public CalculatorController() { this.delimiterCalculator = new DelimiterCalculator(); } ...} public class Ap.. 2024. 10. 23.