[LeetCode] 2337. Move Pieces to Obtain a String (Python)
·
알고리즘/LeetCode
난이도: Medium문제 설명You are given two strings start and target, both of length n. Each string consists only of the characters 'L', 'R', and '_' where:The characters 'L' and 'R' represent pieces, where a piece 'L' can move to the left only if there is a blank space directly to its left, and a piece 'R' can move to the right only if there is a blank space directly to its right.The character '_' repres..
[LeetCode] 769. Max Chunks To Make Sorted (Python)
·
알고리즘/LeetCode
난이도: Medium문제 설명You are given an integer array arr of length n that represents a permutation of the integers in the range [0, n - 1]. We split arr into some number of chunks (i.e., partitions), and individually sort each chunk. After concatenating them, the result should equal the sorted array. Return the largest number of chunks we can make to sort the array. 문제 예제Example 1:Input: arr = [4,3,2,..
[LeetCode] 1475. Final Prices With a Special Discount in a Shop (Python)
·
알고리즘/LeetCode
난이도: Easy문제 설명You are given an integer array prices where prices[i] is the price of the ith item in a shop. There is a special discount for items in the shop. If you buy the ith item, then you will receive a discount equivalent to prices[j] where j is the minimum index such that j > i and prices[j]  Return an integer array answer where answer[i] is the final price you will pay for the ith item o..
[LeetCode] 2182. Construct String With Repeat Limit (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명You are given a string s and an integer repeatLimit. Construct a new string repeatLimitedString using the characters of s such that no letter appears more than repeatLimit times in a row. You do not have to use all characters from s. Return the lexicographically largest repeatLimitedString possible. A string a is lexicographically larger than a string b if in the first position ..
[LeetCode] 3264. Final Array State After K Multiplication Operations I (Python)
·
알고리즘/LeetCode
난이도: Easy 문제 설명You are given an integer array nums, an integer k, and an integer multiplier.You need to perform k operations on nums. In each operation:Find the minimum value x in nums. If there are multiple occurrences of the minimum value, select the one that appears first.Replace the selected minimum value x with x * multiplier.Return an integer array denoting the final state of nums after pe..
[LeetCode] 1792. Maximum Average Pass Ratio (Python)
·
알고리즘/LeetCode
난이도: Medium문제 설명There is a school that has classes of students and each class will be having a final exam. You are given a 2D integer array classes, where classes[i] = [passi, totali]. You know beforehand that in the ith class, there are totali total students, but only passi number of students will pass the exam. You are also given an integer extraStudents. There are another extraStudents brilli..