All Posts

Leetcode 2284: Sender With Largest Word Count

You are given two arrays: one containing a series of messages, and another with the names of the senders corresponding to each message. A message is a list of words separated by spaces. Your task is to determine which sender has sent the most words across all their messages. If there is a tie for the most words, return the sender with the lexicographically larger name.

Leetcode 2288: Apply Discount to Prices

You are given a sentence, which contains words that may include prices represented by a dollar sign (’$’) followed by a sequence of digits. For each word in the sentence that represents a price, apply a given discount percentage and update the word. The price should be updated with exactly two decimal places. The goal is to return a modified sentence where the updated prices reflect the discount.

Leetcode 2295: Replace Elements in an Array

You are given a list of distinct positive integers, nums, and a list of operations. Each operation consists of two elements: operations[i][0] and operations[i][1]. In each operation, you need to replace the element operations[i][0] in nums with the new value operations[i][1]. The number operations[i][1] is guaranteed to not already be in nums. After performing all the operations, return the final array.

Leetcode 2300: Successful Pairs of Spells and Potions

You are given two arrays: spells and potions, representing the strength of spells and potions, respectively. Each element in the arrays represents the strength of a specific spell or potion. You are also given an integer success, which defines the minimum product of a spell and a potion required for a successful pair. For each spell, determine how many potions can pair with it to form a successful combination (i.e., their product is greater than or equal to success).

Leetcode 2304: Minimum Path Cost in a Grid

You are given a 0-indexed m x n integer matrix grid consisting of distinct integers from 0 to m * n - 1. You can move in this matrix from a cell to any other cell in the next row. That is, if you are in cell (x, y) such that x < m - 1, you can move to any of the cells (x + 1, 0), (x + 1, 1), …, (x + 1, n - 1). The move from cells in the last row can be ignored. Each possible move has a cost given by the moveCost matrix, where moveCost[i][j] represents the cost of moving from a cell with value i to a cell in column j of the next row.

Leetcode 2305: Fair Distribution of Cookies

You are given an integer array cookies, where each element represents the number of cookies in a particular bag. You are also given an integer k, which denotes the number of children to distribute these bags of cookies to. Each bag must go to exactly one child, and cookies cannot be split between children. The unfairness of a distribution is defined as the maximum number of cookies any single child receives. Your goal is to return the minimum unfairness across all possible distributions.