[LeetCode] 3375. Minimum Operations to Make Array Values Equal to K (Python)
·
알고리즘/LeetCode
난이도: EasyProblem DescriptionYou are given an integer array nums and an integer k. An integer h is called valid if all values in the array that are strictly greater than h are identical. For example, if nums = [10, 8, 10, 8], a valid integer is h = 9 because all nums[i] > 9 are equal to 10, but 5 is not a valid integer. You are allowed to perform the following operation on nums:Select an integer ..
[LeetCode] 3396. Minimum Number of Operations to Make Elements in Array Distinct (Python)
·
알고리즘/LeetCode
난이도: EasyProblem DescriptionYou are given an integer array nums. You need to ensure that the elements in the array are distinct. To achieve this, you can perform the following operation any number of times:Remove 3 elements from the beginning of the array. If the array has fewer than 3 elements, remove all remaining elements.Note that an empty array is considered to have distinct elements. Retur..
[LeetCode] 416. Partition Equal Subset Sum (C++)
·
알고리즘/LeetCode
난이도: MediumProblem DescriptionGiven an integer array nums, return true if you can partition the array into two subsets such that the sum of the elements in both subsets is equal or false otherwise. Problem ExampleExample 1:Input: nums = [1,5,11,5]Output: trueExplanation: The array can be partitioned as [1, 5, 5] and [11].Example 2:Input: nums = [1,2,3,5]Output: falseExplanation: The array cannot..
[LeetCode] 2873. Maximum Value of an Ordered Triplet I (Python)
·
알고리즘/LeetCode
난이도: EasyProblem DescriptionYou are given a 0-indexed integer array nums. Return the maximum value over all triplets of indices (i, j, k) such that i . If all such triplets have a negative value, return 0. The value of a triplet of indices (i, j, k) is equal to (nums[i] - nums[j]) * nums[k]. Problem ExampleExample 1:Input: nums = [12,6,1,2,7]Output: 77Explanation: The value of the triplet (0, 2,..
[LeetCode] 2140. Solving Questions With Brainpower (Python)
·
알고리즘/LeetCode
난이도: MediumProblem DescriptionYou are given a 0-indexed 2D integer array questions where questions[i] = [pointsi, brainpoweri]. The array describes the questions of an exam, where you have to process the questions in order (i.e., starting from question 0) and make a decision whether to solve or skip each question. Solving question i will earn you pointsi points but you will be unable to solve ea..
[LeetCode] 2780. Minimum Index of a Valid Split (Python)
·
알고리즘/LeetCode
난이도: MediumProblem DescriptionAn element x of an integer array arr of length m is dominant if more than half the elements of arr have a value of x. You are given a 0-indexed integer array nums of length n with one dominant element. You can split nums at an index i into two arrays nums[0, ..., i] and nums[i + 1, ..., n - 1], but the split is only valid if:0 nums[0, ..., i], and nums[i + 1, ..., n..