js
백준 / 그래프 / 17086번 / 아기 상어 2 / JS
17086번: 아기 상어 2 첫째 줄에 공간의 크기 N과 M(2 ≤ N, M ≤ 50)이 주어진다. 둘째 줄부터 N개의 줄에 공간의 상태가 주어지며, 0은 빈 칸, 1은 아기 상어가 있는 칸이다. 빈 칸과 상어의 수가 각각 한 개 이상인 입력만 www.acmicpc.net const fs = require('fs'); const filePath = process.platform === 'linux' ? '/dev/stdin' : '../input.txt'; const input = fs.readFileSync(filePath).toString().trim().split('\n'); const [N, M] = input.shift().split(' ').map(Number); cons..
백준 / 구현 / 16967번 / 배열 복원하기 / JS
16967번: 배열 복원하기 크기가 H × W인 배열 A와 두 정수 X와 Y가 있을 때, 크기가 (H + X) × (W + Y)인 배열 B는 배열 A와 배열 A를 아래로 X칸, 오른쪽으로 Y칸 이동시킨 배열을 겹쳐 만들 수 있다. 수가 겹쳐지면 수가 합쳐 www.acmicpc.net const fs = require('fs'); const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt'; const input = fs.readFileSync(filePath).toString().split('\n'); /** * H: A의 세로, W: A의 가로, X: 밑으로 움직인 칸 수, Y: 오른쪽으로 움직인 칸 수 ..
백준 / 백트래킹 / 18429번 / 근손실 / JS
18429번: 근손실 웨이트 트레이닝을 좋아하는 어떤 대학원생은, 현재 3대 운동 중량 500의 괴력을 소유하고 있다. 다만, 하루가 지날 때마다 중량이 K만큼 감소한다. 예를 들어 K=4일 때, 3일이 지나면 중량이 488로 www.acmicpc.net const fs = require('fs'); const filePath = process.platform === 'linux' ? '/dev/stdin' : '../input.txt'; const input = fs.readFileSync(filePath).toString().split('\n'); const [N, K] = input.shift().split(' ').map(Number); const WEIGHT_LIST = i..
백준 / 그래프 / 1189번 / 컴백홈 / JS
1189번: 컴백홈 첫 줄에 정수 R(1 ≤ R ≤ 5), C(1 ≤ C ≤ 5), K(1 ≤ K ≤ R×C)가 공백으로 구분되어 주어진다. 두 번째부터 R+1번째 줄까지는 R×C 맵의 정보를 나타내는 '.'과 'T'로 구성된 길이가 C인 문자열이 주어진다 www.acmicpc.net const fs = require('fs'); const filePath = process.platform === 'linux' ? '/dev/stdin' : '../input.txt'; const input = fs.readFileSync(filePath).toString().split('\n'); const [R, C, K] = input.shift().split(' ').map(Number); c..
LeetCode / Array / 2090번 / K Radius Subarray Averages / JS
K Radius Subarray Averages - LeetCode Can you solve this real interview question? K Radius Subarray Averages - You are given a 0-indexed array nums of n integers, and an integer k. The k-radius average for a subarray of nums centered at some index i with the radius k is the average of all elem leetcode.com 어떤 원이 k만큼의 반지름을 가질 때, 인덱스 하나마다 해당하는 요소를 중심으로 가질 때, 그 안에 들어오는 배열의 요..
LeetCode / Array / 1732번 / Find the Highest Altitude / JS
Find the Highest Altitude - LeetCode Can you solve this real interview question? Find the Highest Altitude - There is a biker going on a road trip. The road trip consists of n + 1 points at different altitudes. The biker starts his trip on point 0 with altitude equal 0. You are given an integ leetcode.com 고도들이 배열로 주어지는데, 고도들을 따라 계속해서 이동했을 때(누적 합), 가장 고도가 높은 곳의 고도를 반환하면 된다..