전체 글

전체 글

    LeetCode / Greedy / 409번 / Longest Palindrome / JS

    Longest Palindrome - LeetCode Can you solve this real interview question? Longest Palindrome - Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters. Letters are case sensitive, for example, leetcode.com 주어진 문자열의 문자들로 만들 수 있는 문자열 중 가장 긴 팰린드롬 문자열을 만들었을 때 그 길이가 몇인지 반환하면 되는 문제이다. * ..

    LeetCode / Greedy / 121번 / Best Time to Buy and Sell Stock / JS

    Best Time to Buy and Sell Stock - LeetCode Can you solve this real interview question? Best Time to Buy and Sell Stock - You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosin leetcode.com 당일의 주가들이 배열로 주어진다. 언제 매수를 해서 언제 매도를 하면 가장 큰 수익을 낼 수 있는지 확인한 후..

    LeetCode / Linked List / 142번 / Linked List Cycle II / JS

    Linked List Cycle II - LeetCode Can you solve this real interview question? Linked List Cycle II - Given the head of a linked list, return the node where the cycle begins. If there is no cycle, return null. There is a cycle in a linked list if there is some node in the list that can be r leetcode.com 순환을 할 수도 있고, 순환하지 않을 수도 있는 Linked List가 주어진다. 만약 어딘가의 위치에서 순환이 이루어지고 있는 ..

    LeetCode / Linked List / 876번 / Middle of Linked List / JS

    Middle of the Linked List - LeetCode Can you solve this real interview question? Middle of the Linked List - Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node. Example 1: [https://assets.leetcode. leetcode.com 여러개의 노드로 연결된 linked list에서 중간 노드를 반환하면 되는 문제이다. 만약 노드의 개수가 짝수라면 중간 노드의 ..

    백준 / 백트래킹 / 15654번 / N과 M (5) / JS

    15654번: N과 M (5) N개의 자연수와 자연수 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. N개의 자연수는 모두 다른 수이다. N개의 자연수 중에서 M개를 고른 수열 www.acmicpc.net /* N과 M (5) */ 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).t..

    Object Method

    ObjectObject 클래스는 JavaScript의 데이터 유형 중 하나를 나타낸다. 다양한 키 모음 및 더 복잡한 엔티티들을 저장하는 데 사용된다. JS의 거의 모든 객체는 Object의 인스턴스이다. JS는 객체 기반의 스크립트 언어이다. 원시 타입을 제외한 나머지는 모두 객체이다. 한마디로 JS는 객체빼면 시체다... 객체는 키(key)와 값(value)쌍으로 이루어진 프로퍼티(property)들의 집합이다.const obj = { key: value, ... }; Object.entries()for...in와 같은 순서로 주어진 객체 자체의 enumerable 속성 [key, value] 쌍의 배열을 반환한다.Object.entries() 에 의해 반환된 배열(array)의 순서는 객체가 정의된..