All Posts

Leetcode 2335: Minimum Amount of Time to Fill Cups

You have a water dispenser that dispenses cold, warm, and hot water. Every second, you can either fill up 2 cups with different types of water, or 1 cup of any type of water. You are given an array ‘amount’ where amount[0], amount[1], and amount[2] represent the number of cold, warm, and hot water cups you need to fill, respectively. Your task is to determine the minimum number of seconds required to fill all the cups.

Leetcode 2357: Make Array Zero by Subtracting Equal Amounts

You are given a non-negative integer array nums. In each operation, you must:

  • Choose a positive integer x that is less than or equal to the smallest non-zero element in nums.
  • Subtract x from every positive element in nums.

Return the minimum number of operations to make every element in nums equal to 0.

Leetcode 2358: Maximum Number of Groups Entering a Competition

You are given a positive integer array grades which represents the grades of students. Your goal is to group these students into ordered non-empty groups where:

  1. The sum of the grades in the i-th group is less than the sum of the grades in the (i + 1)-th group.
  2. The number of students in the i-th group is less than the number of students in the (i + 1)-th group. Return the maximum number of groups that can be formed.

Leetcode 2375: Construct Smallest Number From DI String

You are given a string pattern consisting of the characters ‘I’ and ‘D’, where ‘I’ indicates that the next number in a sequence should be greater, and ‘D’ means the next number should be smaller. You need to construct the lexicographically smallest string num of length n + 1 such that the digits in num follow the conditions set by the pattern. The digits in num must be distinct and range from ‘1’ to ‘9’.

Leetcode 2383: Minimum Hours of Training to Win a Competition

You are preparing for a competition where you will face a series of opponents. Each opponent has a specified energy and experience. To defeat an opponent, your energy and experience must both exceed theirs. Before entering the competition, you are allowed to train to improve your energy or experience. For every hour of training, you can either increase your energy or your experience by one. You need to determine the minimum number of training hours required to defeat all the opponents in order.

Leetcode 2384: Largest Palindromic Number

You are given a string num consisting only of digits. Your task is to form the largest possible palindromic number by rearranging the digits of num. The resulting number should not have leading zeros and must use at least one digit from the string.