All Posts

Leetcode 2866: Beautiful Towers II

You are given an array maxHeights of n integers. Your task is to build n towers in the coordinate line where the height of the i-th tower is between 1 and maxHeights[i]. The configuration is beautiful if the heights form a mountain array, where heights increase to a peak and then decrease afterward. Return the maximum possible sum of the heights of a beautiful tower configuration.

Leetcode 2870: Minimum Number of Operations to Make Array Empty

You are given an array nums consisting of positive integers. You are allowed to perform two types of operations on the array any number of times: (1) Choose two elements that are the same and remove them from the array. (2) Choose three elements that are the same and remove them from the array. Your task is to return the minimum number of operations required to empty the array, or return -1 if it is not possible to empty the array using these operations.

Leetcode 2871: Split Array Into Maximum Number of Subarrays

You are given an array nums consisting of non-negative integers. Your task is to divide the array into subarrays such that the sum of the scores of the subarrays is minimized. The score of a subarray nums[l..r] is defined as nums[l] AND nums[l + 1] AND … AND nums[r], where AND is the bitwise AND operation. Your goal is to return the maximum number of subarrays that you can split the array into while achieving the minimum possible sum of scores.

Leetcode 2874: Maximum Value of an Ordered Triplet II

You are given an array nums of integers. Find the maximum value over all possible triplets of indices (i, j, k) such that i < j < k. The value of a triplet (i, j, k) is calculated as (nums[i] - nums[j]) * nums[k]. If all triplets produce a negative value, return 0.

Leetcode 2875: Minimum Size Subarray in Infinite Array

You are given an array nums and an integer target. The array infinite_nums is created by infinitely appending nums to itself. You need to find the length of the shortest contiguous subarray in infinite_nums whose sum equals the target. If no such subarray exists, return -1.

Leetcode 2895: Minimum Processing Time

You are given multiple processors with 4 cores each and tasks that need to be assigned to these processors. The goal is to compute the minimum time needed to complete all tasks, where the time taken by a processor is determined by the maximum completion time of its assigned tasks.