js
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를 ..
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의 가장 가까운 공통 부모노드를 찾..
LeetCode / Binary Search Tree / 98번 / Validate Binary Search Tree / JS
Validate Binary Search Tree - LeetCode Can you solve this real interview question? Validate Binary Search Tree - Given the root of a binary tree, determine if it is a valid binary search tree (BST). A valid BST is defined as follows: * The left subtree of a node contains only nodes with keys le leetcode.com 주어진 Tree가 유효한 BST(Binary Search Tree)인지 확인해서 boolean 값을 반환하는 문제이다..