본문 바로가기

Algorithm/자료구조

(108)
(C++) - LeetCode (easy) 705. Design HashSet https://leetcode.com/problems/design-hashset/description/ Design HashSet - LeetCode Can you solve this real interview question? Design HashSet - Design a HashSet without using any built-in hash table libraries. Implement MyHashSet class: * void add(key) Inserts the value key into the HashSet. * bool contains(key) Returns whether the value leetcode.com class를 구현해보는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 set을 ..
(C++) - LeetCode (easy) 617. Merge Two Binary Trees https://leetcode.com/problems/merge-two-binary-trees/description/ Merge Two Binary Trees - LeetCode Can you solve this real interview question? Merge Two Binary Trees - You are given two binary trees root1 and root2. Imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to leetcode.com 재귀로 tree를 만드는 문제였습니다. 📕 풀이방법 ..
(C++) - LeetCode (easy) 594. Longest Harmonious Subsequence https://leetcode.com/problems/longest-harmonious-subsequence/description/ Longest Harmonious Subsequence - LeetCode Can you solve this real interview question? Longest Harmonious Subsequence - We define a harmonious array as an array where the difference between its maximum value and its minimum value is exactly 1. Given an integer array nums, return the length of its l leetcode.com 자료구조를 이용한 문제..
(C++) - LeetCode (easy) 590. N-ary Tree Postorder Traversal https://leetcode.com/problems/n-ary-tree-postorder-traversal/description/ N-ary Tree Postorder Traversal - LeetCode Can you solve this real interview question? N-ary Tree Postorder Traversal - Given the root of an n-ary tree, return the postorder traversal of its nodes' values. Nary-Tree input serialization is represented in their level order traversal. Each group of ch leetcode.com n진 tree의 후위순..
(C++) - LeetCode (easy) 589. N-ary Tree Preorder Traversal https://leetcode.com/problems/n-ary-tree-preorder-traversal/description/ 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 pre order를 다진 ..
(C++) - LeetCode (easy) 575. Distribute Candies https://leetcode.com/problems/distribute-candies/description/ Distribute Candies - LeetCode Can you solve this real interview question? Distribute Candies - Alice has n candies, where the ith candy is of type candyType[i]. Alice noticed that she started to gain weight, so she visited a doctor. The doctor advised Alice to only eat n / 2 of the can leetcode.com 자료구조 map을 이요해 해결한 문제였습니다. 📕 풀이방법 📔 입..
(C++) - LeetCode (easy) 572. Subtree of Another Tree https://leetcode.com/problems/subtree-of-another-tree/description/ Subtree of Another Tree - LeetCode Can you solve this real interview question? Subtree of Another Tree - Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise. A subtree of a bin leetcode.com tree 순회 문제였습니다. 📕 풀이방법 📔 풀..
(C++) - LeetCode (easy) 563. Binary Tree Tilt https://leetcode.com/problems/binary-tree-tilt/description/ Binary Tree Tilt - LeetCode Can you solve this real interview question? Binary Tree Tilt - Given the root of a binary tree, return the sum of every tree node's tilt. The tilt of a tree node is the absolute difference between the sum of all left subtree node values and all right subtr leetcode.com 자료구조 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 왼쪽과 오른쪽 s..