PS

    백준 / 그래프 / 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..

    LeetCode / Tree / 437번 / Path Sum III / JS

    Path Sum III - LeetCode Can you solve this real interview question? Path Sum III - Given the root of a binary tree and an integer targetSum, return the number of paths where the sum of the values along the path equals targetSum. The path does not need to start or end at the roo leetcode.com 주어진 트리내에서 targetSum을 만족하는 subtree가 몇개가 존재하는지 반환하는 문제이다. /** * Definition for a bin..

    LeetCode / Tree / 543번 / Diameter of Binary Tree / JS

    Diameter of Binary Tree - LeetCode Can you solve this real interview question? Diameter of Binary Tree - Given the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path leetcode.com diameter를 직역하면 지름이라는 뜻인데... 이 문제에서 지름을 반환하면 된다(?). 문제에서 나타내는 diameter..