본문 바로가기

자료구조8

231115 LeetCode 문제 풀이 1846. Maximum Element After Decreasing and Rearranging https://leetcode.com/problems/maximum-element-after-decreasing-and-rearranging/?envType=daily-question&envId=2023-11-15 1) 문제 설명 You are given an array of positive integers arr. Perform some operations (possibly none) on arr so that it satisfies these conditions: The value of the first element in arr must be 1. The absolute difference betwee.. 2023. 11. 15.
23114 LeetCode 문제 풀이 1930. Unique Length-3 Palindromic Subsequences https://leetcode.com/problems/unique-length-3-palindromic-subsequences/description/?envType=daily-question&envId=2023-11-14 1) 문제 설명 Given a string s, return the number of unique palindromes of length three that are a subsequence of s. Note that even if there are multiple ways to obtain the same subsequence, it is still only counted once. A palindro.. 2023. 11. 14.
231113 LeetCode 문제 풀이 2785. Sort Vowels in a String https://leetcode.com/problems/sort-vowels-in-a-string/description/?envType=daily-question&envId=2023-11-13 1) 문제 설명 Given a 0-indexed string s, permute s to get a new string t such that: All consonants remain in their original places. More formally, if there is an index i with 0 { vowelArray[3]++; indexArray[count++] = index++; } case 'U' -> { vowelArray[4]++; index.. 2023. 11. 13.
231023 LeetCode 문제 풀이 342. Power of Four https://leetcode.com/problems/power-of-four/?envType=daily-question&envId=2023-10-23 1) 문제 설명 Given an integer n, return true if it is a power of four. Otherwise, return false. An integer n is a power of four, if there exists an integer x such that n == 4x. 2) 제한 사항 -231 2023. 10. 23.
231022 LeetCode 문제 풀이 1793. Maximum Score of a Good Subarray https://leetcode.com/problems/maximum-score-of-a-good-subarray/?envType=daily-question&envId=2023-10-22 1) 문제 설명 You are given an array of integers nums (0-indexed) and an integer k. The score of a subarray (i, j) is defined as min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1). A good subarray is a subarray where i 2023. 10. 23.
231021 LeetCode 문제 풀이 (트리, 투 포인터?) 1425. Constrained Subsequence Sum https://leetcode.com/problems/constrained-subsequence-sum/?envType=daily-question&envId=2023-10-21 1) 문제 설명 Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence, nums[i] and nums[j], where i < j, the condition j - i 2023. 10. 21.