All Posts

Leetcode 2558: Take Gifts From the Richest Pile

You are given an integer array gifts where each element represents the number of gifts in different piles. Every second, you pick the pile with the most gifts and leave behind the floor of the square root of the number of gifts. Repeat this operation for k seconds, and return the total number of gifts left in all piles.

Leetcode 2593: Find Score of an Array After Marking All Elements

You are given an array nums consisting of positive integers. Starting with a score = 0, repeatedly select the smallest unmarked integer, add its value to the score, and mark it along with its adjacent elements (if any). Continue this until all elements are marked, then return the final score.

Leetcode 2611: Mice and Cheese

You have two mice and a set of n different types of cheese. Each type of cheese has a different point value when eaten by either mouse. The first mouse must eat exactly k types of cheese, while the second mouse eats the remaining cheese types. Your task is to maximize the total points the two mice can achieve by distributing the cheese types between the mice.

Leetcode 2679: Sum in a Matrix

You are given a 2D array nums where each row represents a set of numbers. You perform operations on the matrix by removing the largest number from each row at each step. After removing the largest number from each row, you identify the highest number amongst all those removed and add it to your score. Repeat this until the matrix becomes empty and return the final score.

Leetcode 2762: Continuous Subarrays

You are given a 0-indexed integer array ’nums’. A subarray of ’nums’ is called continuous if the absolute difference between any two elements in the subarray is less than or equal to 2. Return the total number of continuous subarrays.

Leetcode 2944: Minimum Number of Coins for Fruits

You are given a list of integers ‘prices’, where each element ‘prices[i]’ represents the cost to purchase the ‘i’-th fruit. If you buy the ‘i’-th fruit at prices[i] coins, you get all subsequent fruits for free. Your task is to determine the minimum number of coins required to purchase all the fruits.