목록PS/LeetCode (618)
넘치게 채우기
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..
https://leetcode.com/problems/max-sum-of-a-pair-with-equal-sum-of-digits/description/leetcode - Max Sum of a Pair With Equal Sum of Digits문제 유형: 해시, 그리디문제 난이도: Medium 문제You are given a 0-indexed array nums consisting of positive integers. You can choose two indices i and j, such that i != j, and the sum of digits of the number nums[i] is equal to that of nums[j].Return the maximum value of nums[..
https://leetcode.com/problems/remove-all-occurrences-of-a-substring/description/leetcode - Remove All Occurrences of a Substring문제 유형: 스택, 문자열 처리문제 난이도: Medium 문제Given two strings s and part, perform the following operation on s until all occurrences of the substring part are removed:Find the leftmost occurrence of the substring part and remove it from s.Return s after removing all occurrences o..
https://leetcode.com/problems/clear-digits/description/leetcode - Clear Digits문제 유형: 스택, 문자열 처리문제 난이도: Easy 문제You are given a string s.Your task is to remove all digits by doing this operation repeatedly:Delete the first digit and the closest non-digit character to its left.Return the resulting string after removing all digits. 문자열 s를 받습니다.당신의 임무는 다음을 반복적으로 수행하는 것 입니다:첫 번째 숫자를 지우고 왼쪽의 숫자가 아닌 문자를..
https://leetcode.com/problems/count-number-of-bad-pairs/description/leetcode - Count Number of Bad Pairs문제 유형: 투 포인터, 해시, 정렬, 수학문제 난이도: Medium 문제You are given a 0-indexed integer array nums. A pair of indices (i, j) is a bad pair if i and j - i != nums[j] - nums[i].Return the total number of bad pairs in nums. 0-indexed의 정수 배열 nums가 주어진다.(i, j)페어는 다음 조건을 만족하면 나쁜 페어이다: if i 나쁜 페어의 개수를 구하시오. 풀이전체..
https://leetcode.com/problems/design-a-number-container-system/description/leetcode - Design a Number Container System문제 유형: 우선순위 큐, 힙, 해시문제 난이도: Medium 문제Design a number container system that can do the following:Insert or Replace a number at the given index in the system.Return the smallest index for the given number in the system.Implement the NumberContainers class:NumberContainers() Initial..
https://leetcode.com/problems/find-the-number-of-distinct-colors-among-the-balls/description/leetcode - Find the Number of Distinct Colors Among the Balls문제 유형: 해시문제 난이도: Medium 문제You are given an integer limit and a 2D array queries of size n x 2.There are limit + 1 balls with distinct labels in the range [0, limit]. Initially, all balls are uncolored. For every query in queries that is of the ..