js
LeetCode / String /392번 / Is Subsequence / JS
Is Subsequence - LeetCode Can you solve this real interview question? Is Subsequence - Given two strings s and t, return true if s is a subsequence of t, or false otherwise. A subsequence of a string is a new string that is formed from the original string by deleting some (can be n leetcode.com 문자열로 s와 t가 주어진다. 이때 주어진 s의 각각 문자가 s에서의 순서를 지키면서 t에 속하는지 판단하면 되는 문제이다. 예를들어 s =..
LeetCode / String / 205번 / Isomorphic Strings / JS
Isomorphic Strings - LeetCode Can you solve this real interview question? Isomorphic Strings - Given two strings s and t, determine if they are isomorphic. Two strings s and t are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replace leetcode.com 문자열 s와 t가 주어지면 둘이 같은 패턴을 가지는지 판단하여 return 하면되는 문제이다. 예를들어 egg와 add가 각각 s와 ..
LeetCode / Prefix Sum / 724번 / Find Pivot Index / JS
Find Pivot Index - LeetCode Can you solve this real interview question? Find Pivot Index - Given an array of integers nums, calculate the pivot index of this array. The pivot index is the index where the sum of all the numbers strictly to the left of the index is equal to the sum of leetcode.com nums 배열에서 한 index를 pivot으로 삼았을 때, 그 pivot의 왼쪽에 있는 값들을 다 더한 값과 오른쪽에 있는 값들을 다 더..
LeetCode / Prefix Sum / 1480번 / Running Sum of 1d Array / JS
Running Sum of 1d Array - LeetCode Can you solve this real interview question? Running Sum of 1d Array - Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]). Return the running sum of nums. Example 1: Input: nums = [1,2,3,4] Output: [1,3,6, leetcode.com nums 라는 배열이 주어지면 각 원소를 순회하면서 누적합을 구해서 return 해주면 되는 문제이다. /** * @param {nu..
백준 / 큐 / 1966번 / 프린터 큐 / JS
1966번: 프린터 큐 여러분도 알다시피 여러분의 프린터 기기는 여러분이 인쇄하고자 하는 문서를 인쇄 명령을 받은 ‘순서대로’, 즉 먼저 요청된 것을 먼저 인쇄한다. 여러 개의 문서가 쌓인다면 Queue 자료구조에 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()..
백준 / 그래프 / 2606번 / 바이러스 / JS
2606번: 바이러스 첫째 줄에는 컴퓨터의 수가 주어진다. 컴퓨터의 수는 100 이하이고 각 컴퓨터에는 1번 부터 차례대로 번호가 매겨진다. 둘째 줄에는 네트워크 상에서 직접 연결되어 있는 컴퓨터 쌍의 수가 주어 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().t..