전체 글
LeetCode / Heap / 692번 / Top K Frequent Words / JS
Top K Frequent Words - LeetCode Can you solve this real interview question? Top K Frequent Words - Given an array of strings words and an integer k, return the k most frequent strings. Return the answer sorted by the frequency from highest to lowest. Sort the words with the same frequenc leetcode.com 단어들이 들어있는 배열 words 배열과 정수인 k가 들어온다. words 배열에서 가장 많이 나온 단어들을 순서대로 k개만 반환..
LeetCode / Heap / 1046번 / Last Stone Weight / JS
Last Stone Weight - LeetCode Can you solve this real interview question? Last Stone Weight - You are given an array of integers stones where stones[i] is the weight of the ith stone. We are playing a game with the stones. On each turn, we choose the heaviest two stones and smash them leetcode.com 돌의 무게들이 배열로 들어온다. 그 중에서 가장 큰 두개의 돌의 무게를 x와 y라고 한다. 이때 x는 y이하이다. 만약 x와 y가 같다면..
LeetCode / Stack / 394번 / Decode String / JS
Decode String - LeetCode Can you solve this real interview question? Decode String - Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is g leetcode.com [] 괄호 쌍 안에 있는 문자열을 바로 앞에 온 숫자만큼 반복한다. 예를 들어 "3[a]2[bc]" 일 경우엔, "aaabcbc" 가 된다. ..
LeetCode / Stack / 844번 / Backspace String Compare / JS
Backspace String Compare - LeetCode Can you solve this real interview question? Backspace String Compare - Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character. Note that after backspacing an empty text, the tex leetcode.com 문자열 s와 t가 주어진다. 문자열에 #이 있다면 이전에 입력한 문자는 지워진다. 예를들면, "ab#c" 일 경우엔 a를 ..
Symbol
1. Symbol 이란? Symbol은 원시타입 데이터로, 유일무이한 값을 만드는데 사용된다. (Symbol의 뜻이 상징이라는 뜻이니까...) 그리고 이 값은 익명의 객체 속성(object property)을 만들 수 있는 특성을 가졌다. 한 마디로 객체의 키값은 문자열, 뿐만 아니라 Symbol형도 가능하다. Symbol() 을 사용하면 Symbol 값을 만들 수 있다. // id는 새로운 심볼이 됩니다. let id = Symbol(); 아래와 같이 Symbol을 만들 때 인자를 줄 수 있는데, 이 인자는 Symbol을 나타내는 설명, 이름이다. 이 Symbol 이름은 어떠한 것에도 영향을 주지 않는 단순 '이름'역할만 한다. 디버깅시에 많이 쓰인다. // 심볼 id에는 "id"라는 설명이 붙습니다...
LeetCode / Binary Search Tree / 235번 / Lowest Common Ancestor of a Binary Search Tree / JS
Lowest Common Ancestor of a Binary Search Tree - LeetCode Can you solve this real interview question? Lowest Common Ancestor of a Binary Search Tree - Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST. According to the definition of LCA on Wikipedia [https: leetcode.com TreeNode인 p와 q가 주어지는데, p와 q의 가장 가까운 공통 부모노드를 찾..