본문 바로가기
728x90
반응형

전체 글279

637. Average of Levels in Binary Tree 이진 트리의 각 레벨에 있는 노드들의 평균 값을 계산하는 문제입니다. 이진 트리의 루트가 주어지면, 각 레벨의 노드들의 평균 값을 배열 형태로 반환해야 합니다.이진 트리의 각 레벨에 있는 노드들의 평균 값을 계산하는 문제입니다. 이진 트리의 루트가 주어지면, 각 레벨의 노드들의 평균 값을 배열 형태로 반환해야 합니다. 실제 답과 10^-5 이내의 오차는 허용됩니다. /** * Definition for a binary tree node. * public class TreeNode { * public int val; * public TreeNode left; * public TreeNode right; * public TreeNode(int val=0, TreeNode left=null, TreeNode .. 2024. 4. 18.
98. Validate Binary Search Tree 이진 트리가 유효한 이진 탐색 트리(Binary Search Tree, BST)인지 판별하는 것입니다. 노드의 왼쪽 서브트리에는 노드의 키보다 작은 키를 가진 노드만 포함되어 있습니다. 노드의 오른쪽 서브트리에는 노드의 키보다 큰 키를 가진 노드만 포함되어 있습니다. 왼쪽과 오른쪽 서브트리 모두 이진 탐색 트리여야 합니다. 예시 1: 입력: root = [2,1,3], 출력: true 예시 2: 입력: root = [5,1,4,null,null,3,6], 출력: false. 설명: 루트 노드의 값은 5이지만, 그 오른쪽 자식 노드의 값은 4입니다. 트리의 노드 수는 범위 [1, 10^4] 내에 있습니다. 노드의 값은 -2^31 2024. 4. 17.
findProfession 이진 트리의 특정 레벨과 위치에 있는 사람의 직업을 결정하는 문제입니다. 만약 레벨이 1인 경우, 해당 사람의 직업은 "Engineer"입니다. 그렇지 않은 경우, 해당 사람의 직업은 부모의 직업에 따라 결정됩니다. 부모가 "Engineer"인 경우, 해당 사람의 위치에 따라 “Engineer” 또는 "Doctor"로 번갈아가며 결정됩니다. 부모가 "Doctor"인 경우, 해당 사람의 위치에 따라 직업이 반대로 결정됩니다 (짝수 위치는 “Engineer”, 홀수 위치는 “Doctor”). string solution(int level, int pos) { return findProfession(level,pos); } string findProfession(int level,int pos){ if(pos.. 2024. 4. 8.
CI/CD CI/CD, or Continuous Integration and Continuous Delivery, automates the software development process from the initial code commit all the way through to deployment. It eliminates much of the manual human intervention traditionally required to get new code to production. This process takes care of building,testing, and deploying new code to production. The promise is that it enables software team.. 2024. 4. 8.
isTreeSymmetric 주어진 이진 트리가 중심을 기준으로 대칭인지 여부를 판단하는 문제입니다. 이를 확인하기 위해서는 각 측면이 서로 거울처럼 반영되는지 확인해야 합니다. 트리가 비어 있으면 대칭이라고 판단합니다. 그렇지 않은 경우, 왼쪽 서브트리와 오른쪽 서브트리를 비교하여 값이 같은지 확인합니다. 서브트리들이 대칭적으로 구성되어 있는지 재귀적으로 확인합니다. // // Binary trees are already defined with this interface: // class Tree { // public T value { get; set; } // public Tree left { get; set; } // public Tree right { get; set; } // } bool solution(Tree t) { .. 2024. 4. 5.
hasPathWithGivenSum 이진 트리에서 특정 합계를 갖는 경로가 있는지 확인하는 문제를 해결하는 함수입니다. 주어진 이진 트리는 각 노드가 정수 값을 가지고 있습니다. // // Binary trees are already defined with this interface: // class Tree { // public T value { get; set; } // public Tree left { get; set; } // public Tree right { get; set; } // } bool solution(Tree t, int s) { return hasPathWithGivenSum(t,s); } bool hasPathWithGivenSum(Tree t, int s){ if(t == null) return false; i.. 2024. 4. 2.
Kubernetes Kubernetes is an open-source container orchestration platform. It automates the deployment, scaling, and management of containerized applications. A Kubernetes cluster is a set of machines, called nodes, that are used to run containerized applications. There are two core pieces in a Kubernetes cluster. The first is the control plane. It is responsible for managing the state of the cluster. In PR.. 2024. 4. 1.
Async Functions in Javascript import React, { useState, useEffect } from 'react'; function DataFetcher() { const [data, setData] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { async function fetchData() { try { const data = await fetchData('https://api.example.com/data'); setData(data); setLoading(false); } catch (error) { setError(error); setLoadin.. 2024. 4. 1.
728x90
반응형