All Posts

Leetcode 1760: Minimum Limit of Balls in a Bag

You are given an array nums where each element represents the number of balls in a bag. You can perform up to maxOperations operations, where each operation consists of splitting one bag of balls into two smaller bags. Each new bag must contain a positive number of balls. The goal is to minimize the maximum number of balls in any bag after performing the operations.

Leetcode 1764: Form Array by Concatenating Subarrays of Another Array

Given an array of subarrays groups and a single array nums, your task is to determine whether it is possible to extract each subarray from groups as a contiguous segment from nums. The subarrays must appear in the same order as in groups, and they should be disjoint, meaning no element from nums can belong to more than one subarray. Return true if this is possible, and false otherwise.

Leetcode 1765: Map of Highest Peak

Given a 2D grid where each cell is either water (1) or land (0), assign heights to the land cells such that the height difference between adjacent cells is at most 1. The goal is to maximize the height values of land cells while ensuring the height of water cells is 0. Return the grid with assigned heights.

Leetcode 1769: Minimum Number of Operations to Move All Balls to Each Box

You are given a binary string boxes of length n, where each character represents whether a box is empty (‘0’) or contains a ball (‘1’). Your task is to calculate, for each box, the minimum number of operations required to move all the balls to that particular box. An operation involves moving a ball from one box to an adjacent box.

Leetcode 1774: Closest Dessert Cost

You are planning to make a custom dessert by choosing an ice cream base and toppings. The dessert must follow these rules: You must select one ice cream base. You can add one or more types of toppings, or choose to skip toppings. You can add at most two of each topping type. You are given an array representing the base costs and topping costs. The goal is to create a dessert where the total cost is as close as possible to the target price. If there are multiple dessert combinations that meet the target price, return the lower cost.

Leetcode 1775: Equal Sum Arrays With Minimum Number of Operations

You are given two arrays, nums1 and nums2, with integers between 1 and 6. The lengths of the two arrays can differ. In one operation, you can change any element in either array to any value between 1 and 6. The task is to find the minimum number of operations required to make the sums of the two arrays equal. If it is not possible to make the sums equal, return -1.