본문 바로가기
728x90
반응형

전체 글274

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.
Process VS Thread Process example: Google Chrome uses Process isolation by running each tab in its own process. When one tab misbehaves due to a bug or a malicious attack, other tabs are unaffected. What is a thread? A thread is the unit of execution within a process. A process has at least on thread It is called the main thread. It is not uncommon for a process to have many threads. Each thread has its own stack.. 2024. 4. 1.
2089. Find Target Indices After Sorting Array 0으로 시작하는 정수 배열 nums와 목표 요소 target이 주어집니다. 목표 인덱스는 nums[i] == target인 인덱스 i입니다. nums를 비감소 순서로 정렬한 후 nums의 목표 인덱스 목록을 반환하십시오. 목표 인덱스가 없으면 빈 목록을 반환합니다. 반환된 목록은 증가 순서로 정렬되어야 합니다. 예를 들어: 예제 1: 입력: nums = [1,2,5,2,3], target = 2 출력: [1,2] 설명: 정렬 후, nums는 [1, 2, 2 ,3,5]입니다. nums[i] == 2인 인덱스는 1과 2입니다. 예제 2: 입력: nums = [1,2,5,2,3], target = 3 출력: [3] 설명: 정렬 후, nums는 [1,2,2, 3 ,5]입니다. nums[i] == 3인 인덱스는 .. 2024. 3. 27.
rearrangeLastN 단일 연결 리스트에서 마지막 n개의 노드를 리스트의 시작 부분으로 이동 주어진 단일 연결 리스트에서 마지막 n개의 노드를 리스트의 시작 부분으로 이동시켜야 합니다. 예를 들어: 입력 리스트가 [1, 2, 3, 4, 5]이고 n이 3이면, 결과는 [3, 4, 5, 1, 2]가 되어야 합니다. 입력 리스트가 [1, 2, 3, 4, 5, 6, 7]이고 n이 1이면, 결과는 [7, 1, 2, 3, 4, 5, 6]이 되어야 합니다. // Singly-linked lists are already defined with this interface: // class ListNode { // public T value { get; set; } // public ListNode next { get; set; } // } .. 2024. 3. 20.
reverseNodesInKGroups 주어진 연결 리스트 l의 노드들을 크기 k씩 뒤집고 수정된 리스트를 반환해야 합니다. k는 양수이며, l의 길이보다 작거나 같아야 합니다. 만약 연결 리스트의 노드 수가 k의 배수가 아니라면, 뒤에 남은 노드는 그대로 유지되어야 합니다. 노드의 값은 변경할 수 없으며, 노드 자체만 변경할 수 있습니다. 예시: 예시 1: l = [1, 2, 3, 4, 5]이고 k = 2인 경우, 출력은 [2, 1, 4, 3, 5]가 되어야 합니다. 예시 2: l = [1, 2, 3, 4, 5]이고 k = 1인 경우, 출력은 [1, 2, 3, 4, 5]가 되어야 합니다. 예시 3: l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]이고 k = 3인 경우, 출력은 [3, 2, 1, 6, 5, 4, 9, 8.. 2024. 3. 15.
mergeTwoLinkedLists 두 개의 오름차순으로 정렬된 단일 연결 리스트가 주어졌을 때, 이 두 리스트를 병합하는 것입니다. 병합된 리스트도 오름차순으로 정렬되어야 합니다. 즉, 첫 번째 두 리스트의 노드를 연결하여 새로운 단일 연결 리스트를 만들어야 합니다. 이 문제를 풀기 위해서는 O(l1.length + l2.length) 시간 복잡도를 가져야 합니다. 이것이 면접에서 요구되는 작업입니다. 예를 들어, 다음과 같은 두 개의 연결 리스트가 주어졌다고 가정해 봅시다: 리스트 1: 1 -> 3 -> 5 리스트 2: 2 -> 4 -> 6 이 두 리스트를 병합하면 다음과 같은 결과가 나와야 합니다: 병합된 리스트: 1 -> 2 -> 3 -> 4 -> 5 -> 6 이 문제를 풀기 위해서는 두 리스트를 순회하면서 노드를 비교하고 새로운 .. 2024. 3. 14.
728x90
반응형