[LeetCode] 1962. Remove Stones to Minimize the Total (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명You are given a 0-indexed integer array piles, where piles[i] represents the number of stones in the ith pile, and an integer k. You should apply the following operation exactly k times: Choose any piles[i] and remove floor(piles[i] / 2) stones from it.Notice that you can apply the operation on the same pile more than once. Return the minimum possible total number of stones rema..
[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..
[LeetCode] 2593. Find Score of an Array After Marking All Elements (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명You are given an array nums consisting of positive integers.Starting with score = 0, apply the following algorithm:Choose the smallest integer of the array that is not marked. If there is a tie, choose the one with the smallest index.Add the value of the chosen integer to score.Mark the chosen element and its two adjacent elements if they exist.Repeat until all the array element..
[LeetCode] 2558. Take Gifts From the Richest Pile (Python)
·
알고리즘/LeetCode
난이도: Easy 문제 설명You are given an integer array gifts denoting the number of gifts in various piles. Every second, you do the following:Choose the pile with the maximum number of gifts.If there is more than one pile with the maximum number of gifts, choose any.Leave behind the floor of the square root of the number of gifts in the pile. Take the rest of the gifts.Return the number of gifts remaini..