All Posts

Leetcode 2144: Minimum Cost of Buying Candies With Discount

A shop offers a special deal: for every two candies you purchase, you get a third candy for free. The free candy must have a cost that is less than or equal to the minimum cost of the two candies purchased. Calculate the minimum cost of purchasing all candies.

Leetcode 2160: Minimum Sum of Four Digit Number After Splitting Digits

You are given a four-digit integer ’num’. Your task is to split this number into two new integers, ’new1’ and ’new2’, by rearranging its digits. The digits in ’num’ must be used in their entirety, and leading zeros are allowed in ’new1’ and ’new2’. Your goal is to return the minimum possible sum of ’new1’ and ’new2'.

Leetcode 2170: Minimum Operations to Make the Array Alternating

You are given a 0-indexed array nums consisting of n positive integers. The array nums is called alternating if nums[i - 2] == nums[i] and nums[i - 1] != nums[i] for all valid i. In one operation, you can choose an index i and change nums[i] into any positive integer. Your task is to return the minimum number of operations required to make the array alternating.

Leetcode 2171: Removing Minimum Number of Magic Beans

You are given an array of positive integers representing the number of magic beans in each bag. Your task is to remove some beans (possibly none) from each bag so that the number of beans in each remaining non-empty bag is equal. You need to find the minimum number of beans to remove.

Leetcode 2178: Maximum Split of Positive Even Integers

Given an integer finalSum, split it into a sum of as many unique positive even integers as possible. If such a split is not possible, return an empty array.

Leetcode 2182: Construct String With Repeat Limit

Given a string of lowercase letters and an integer limit, construct a new string such that no character appears more than the given limit times consecutively. The new string should be lexicographically largest while satisfying this condition. You can use any subset of characters from the given string.