목록LeetCode (546)
넘치게 채우기
https://riveroverflow.hashnode.dev/series/dsa-and-cp
https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal/description/leetcode - Construct Binary Tree from Preorder and Postorder Traversal문제 유형: 트리, 분할 정복문제 난이도: Medium 문제Given two integer arrays, preorder and postorder where preorder is the preorder traversal of a binary tree of distinct values and postorder is the postorder traversal of the same tree, reconstr..
https://leetcode.com/problems/recover-a-tree-from-preorder-traversal/description/leetcode - Recover a Tree From Preorder Traversal문제 유형: 스택, 트리, dfs, 문자열 처리문제 난이도: Hard 문제We run a preorder depth-first search (DFS) on the root of a binary tree.At each node in this traversal, we output D dashes (where D is the depth of this node), then we output the value of this node. If the depth of a node is D..
https://leetcode.com/problems/find-elements-in-a-contaminated-binary-tree/description/?envType=daily-question&envId=2025-02-21leetcode - Find Elements in a Contaminated Binary Tree문제 유형: 트리, 해시문제 난이도: Medium 문제Given a binary tree with the following rules:root.val == 0For any treeNode:If treeNode.val has a value x and treeNode.left != null, then treeNode.left.val == 2 * x + 1If treeNode.val has a..
https://leetcode.com/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/description/leetcode - The k-th Lexicographical String of All Happy Strings of Length n문제 유형: 백트래킹, 수학, 조합론, 해 구성하기문제 난이도: Medium 문제A happy string is a string that:consists only of letters of the set ['a', 'b', 'c'].s[i] != s[i + 1] for all values of i from 1 to s.length - 1 (string is 1-indexed).For e..
https://leetcode.com/problems/construct-smallest-number-from-di-string/description/leetcode - Construct Smallest Number From DI String문제 유형: 백트래킹, 비트마스킹, 문자열 처리, 그리디문제 난이도: Medium 문제You are given a 0-indexed string pattern of length n consisting of the characters 'I' meaning increasing and 'D' meaning decreasing.A 0-indexed string num of length n + 1 is created using the following conditions:num..
https://leetcode.com/problems/construct-the-lexicographically-largest-valid-sequence/description/leetcode - Construct the Lexicographically Largest Valid Sequence문제 유형: dfs, 재귀, 백트래킹, 비트마스킹문제 난이도: Medium 문제Given an integer n, find a sequence that satisfies all of the following:The integer 1 occurs once in the sequence.Each integer between 2 and n occurs twice in the sequence.For every integer i ..
https://leetcode.com/problems/find-the-punishment-number-of-an-integer/leetcode - FInd the Punishment Number of an Integer문제 유형: 백트래킹문제 난이도: Medium 문제Given a positive integer n, return the punishment number of n.The punishment number of n is defined as the sum of the squares of all integers i such that:1 The decimal representation of i * i can be partitioned into contiguous substrings such that ..
https://leetcode.com/problems/product-of-the-last-k-numbers/description/Product of the Last K Numbers문제 유형: 부분합, 슬라이딩 윈도우문제 난이도: Medium 문제Design an algorithm that accepts a stream of integers and retrieves the product of the last k integers of the stream.Implement the ProductOfNumbers class:ProductOfNumbers() Initializes the object with an empty stream.void add(int num) Appends the integer num t..
https://leetcode.com/problems/minimum-operations-to-exceed-threshold-value-ii/description/leetcode - Minimum Operations to Exceed Threshold Value II문제 유형: 우선순위 큐, 힙, 그리디문제 난이도: Medium 문제You are given a 0-indexed integer array nums, and an integer k.In one operation, you will:Take the two smallest integers x and y in nums.Remove x and y from nums.Add min(x, y) * 2 + max(x, y) anywhere in the arra..