전체 글

전체 글

    LeetCode / Tree / 102번 / Binary Tree Level Order Traversal / JS

    Binary Tree Level Order Traversal - LeetCode Can you solve this real interview question? Binary Tree Level Order Traversal - Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level). Example 1: [https://assets.leetcode.com/u leetcode.com Level Order, 즉 한 Level(=depth)씩 탐색하는 문제이다. BFS와 같다. /** * Defi..

    LeetCode / Tree / 589번 / N-ary Tree Preorder Traversal / JS

    N-ary Tree Preorder Traversal - LeetCode Can you solve this real interview question? N-ary Tree Preorder Traversal - Given the root of an n-ary tree, return the preorder traversal of its nodes' values. Nary-Tree input serialization is represented in their level order traversal. Each group of chil leetcode.com 전위순회로 트리를 탐색하는 문제이다. 전위순회의 순서는 왼쪽 하위노드 -> 루트 -> 오른쪽 하위노드의 순서이다...

    얕은 복사와 깊은 복사(Shallow Copy & Deep Copy)

    서론얕은 복사와 깊은 복사에 대해 정리하다보니 여러 개념이 얽혀있고, 그에 대한 이해가 필요하다는 것을 알게됐다.나도 얕은 복사와 깊은 복사에 대해 굉장히 많이 헷갈렸었고, 지금도 가끔 헷갈리는 개념이므로 처음부터 정리하고자 한다. 원시타입과 참조타입Javascript 에는 원시타입과 참조타입이 존재한다. 각각 타입에 무엇이 존재하는지 알아보고, 그 둘의 차이점을 안다면 이번 포스팅의 주제인 얕은 복사와 깊은 복사에 대해 이해하기 쉬워질 것이라 생각한다.1. 원시타입Javascript의 원시타입에 다음과 같은 타입들이 존재한다.stringnumberbigintbooleanundefinednullsymbol (ES6+)원시타입은 메모리에 저장될 때 '불변성'을 가지고 있다. 일단 아래 코드를 보자.let ..

    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가 주어진다. 만약 어딘가의 위치에서 순환이 이루어지고 있는 ..