분류 전체보기
LeetCode / Binary Search Tree / 230번 / Kth Smallest Element in a BST / JS
Kth Smallest Element in a BST - LeetCode Can you solve this real interview question? Kth Smallest Element in a BST - Given the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the tree. Example 1: [https://assets.leetco leetcode.com BST(Binary Search Tree) 에서 K번째로 작은 노드의 값을 반환하는 문제이다. /** * Definit..
LeetCode / Binary Search Tree / 108번 / Convert Sorted Array to Binary Search Tree / JS
Convert Sorted Array to Binary Search Tree - LeetCode Can you solve this real interview question? Convert Sorted Array to Binary Search Tree - Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree. Example 1: [https://assets.leetcod leetcode.com input으로 들어온 정렬된 배열을 이진 탐색 트리로 변환하는 문제이다. /** * Defini..
백준 / 그래프 / 2178번 / 미로 탐색 / JS
2178번: 미로 탐색 첫째 줄에 두 정수 N, M(2 ≤ N, M ≤ 100)이 주어진다. 다음 N개의 줄에는 M개의 정수로 미로가 주어진다. 각각의 수들은 붙어서 입력으로 주어진다. www.acmicpc.net /* 미로 탐색 */ const fs = require('fs'); const filePath = process.platform === 'linux' ? '/dev/stdin' : '../input.txt'; // const filePath = process.platform === 'linux' ? '/dev/stdin' : 'BOJ/input.txt'; const input = fs.readFileSync(filePath).toString().trim().split('\..
백준 / 그래프 / 7569번 / 토마토 / JS
7569번: 토마토 첫 줄에는 상자의 크기를 나타내는 두 정수 M,N과 쌓아올려지는 상자의 수를 나타내는 H가 주어진다. M은 상자의 가로 칸의 수, N은 상자의 세로 칸의 수를 나타낸다. 단, 2 ≤ M ≤ 100, 2 ≤ N ≤ 100, www.acmicpc.net 큐를 직접 구현하지 않고 BFS를 했을 때 shift() 메소드를 사용하면 시간초과가 나서 어쩔 수 없이 구현해야 했다. 흔히 하던 전형적인 BFS 방식에서 차원수가 하나 더 늘어난 것 빼고는 크게 다를것은 없는 문제였다. /* 토마토 */ const fs = require('fs'); const filePath = process.platform === 'linux' ? '/dev/stdin' : '../input.t..
LeetCode / Binary Search / 33번 / Search in Rotated Sorted Array / JS
Search in Rotated Sorted Array - LeetCode Can you solve this real interview question? Search in Rotated Sorted Array - There is an integer array nums sorted in ascending order (with distinct values). Prior to being passed to your function, nums is possibly rotated at an unknown pivot index k (1 정렬된 배열이 원형큐처럼 몇번 회전이 되었을지 알 수 없는 배열에서 target 값을 찾는 문제이다. /** * @param {number[]} nums * @p..
LeetCode / Binary Search / 74번 / Search a 2D Matrix / JS
Search a 2D Matrix - LeetCode Can you solve this real interview question? Search a 2D Matrix - You are given an m x n integer matrix matrix with the following two properties: * Each row is sorted in non-decreasing order. * The first integer of each row is greater than the last integer leetcode.com 주어진 2차원 배열에서 target 값이 존재하는지 찾는 문제이다. 그냥 간단히 할 수도 있겠지만... topic이 Binary Sea..