LeetCode

    LeetCode / String / 14번 / Longest Common Prefix / JS

    Longest Common Prefix - LeetCode Can you solve this real interview question? Longest Common Prefix - Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: strs = ["flower","flow" leetcode.com 모든 문자열들에게 공통되는 가장 긴 접두사를 찾아서 반환한다. /** * @param {string[]} strs * @return ..

    LeetCode / Simulation / 54번 / Spiral Matrix / JS

    Spiral Matrix - LeetCode Can you solve this real interview question? Spiral Matrix - Given an m x n matrix, return all elements of the matrix in spiral order. Example 1: [https://assets.leetcode.com/uploads/2020/11/13/spiral1.jpg] Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] Outpu leetcode.com 위와 같은 규칙을 가지면서 이동할 때, 이동한 순서를 담긴 배열을 반환한다. /** * @param {number[][]} matrix * @ret..

    LeetCode / Implementation / 202번 / Happy Number / JS

    Happy Number - LeetCode Can you solve this real interview question? Happy Number - Write an algorithm to determine if a number n is happy. A happy number is a number defined by the following process: * Starting with any positive integer, replace the number by the sum of the squar leetcode.com 양의 정수 n이 입력값으로 들어온다. n의 각 자리를 나누어서 각각 제곱을 한 뒤 더해준 것이 다음 수가 된다. 이 과정을 1이 될 때 까지 반..

    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" 가 된다. ..