이진탐색

    [LeetCode] 653. Two Sum IV - Input is a BST

    [LeetCode] 653. Two Sum IV - Input is a BST

    653. Two Sum IV - Input is a BST Easy Given the root of a Binary Search Tree and a target number k, return true if there exist two elements in the BST such that their sum is equal to the given target. Example 1: Input: root = [5,3,6,2,4,null,7], k = 9 Output: true Example 2: Input: root = [5,3,6,2,4,null,7], k = 28 Output: false Constraints: The number of nodes in the tree is in the range [1, 10..

    [LeetCode] 623. Add One Row to Tree

    [LeetCode] 623. Add One Row to Tree

    623. Add One Row to Tree Medium Given the root of a binary tree and two integers val and depth, add a row of nodes with value val at the given depth depth. Note that the root node is at depth 1. The adding rule is: Given the integer depth, for each not null tree node cur at the depth depth - 1, create two tree nodes with value val as cur's left subtree root and right subtree root. cur's original..

    [BOJ] 알고리즘 스터디 boj 1939 중량제한 BFS + BINARY SEARCH

    이번에는 백준 1939 중량 제한을 풀어보자BFS + 이진탐색 으로 풀어야한다. https://www.acmicpc.net/problem/1939 중량제한 성공시간 제한메모리 제한제출정답맞은 사람정답 비율2 초128 MB67011657101624.847%문제N(2≤N≤10,000)개의 섬으로 이루어진 나라가 있다. 이들 중 몇 개의 섬 사이에는 다리가 설치되어 있어서 차들이 다닐 수 있다.영식 중공업에서는 두 개의 섬에 공장을 세워 두고 물품을 생산하는 일을 하고 있다. 물품을 생산하다 보면 공장에서 다른 공장으로 생산 중이던 물품을 수송해야 할 일이 생기곤 한다. 그런데 각각의 다리마다 중량제한이 있기 때문에 무턱대고 물품을 옮길 순 없다. 만약 중량제한을 초과하는 양의 물품이 다리를 지나게 되면 다리..