leetcode.cn 2025-11-03
🟡1578.minimum-time-to-make-rope-colorful
🏷️ Tags
#greedy #array #string #dynamic_programming
🟡1578.minimum-time-to-make-rope-colorful
🏷️ Tags
#greedy #array #string #dynamic_programming
Telegraph
minimum-time-to-make-rope-colorful
Alice 把 n 个气球排列在一根绳子上。给你一个下标从 0 开始的字符串 colors ,其中 colors[i] 是第 i 个气球的颜色。 Alice 想要把绳子装扮成 五颜六色的 ,且她不希望两个连续的气球涂着相同的颜色,所以她喊来 Bob 帮忙。Bob 可以从绳子上移除一些气球使绳子变成 彩色 。给你一个 下标从 0 开始 的整数数组 neededTime ,其中 neededTime[i] 是 Bob 从绳子上移除第 i 个气球需要的时间(以秒为单位)。 返回 Bob 使绳子变成 彩色 需要的…
leetcode.com 2025-11-03
🟡1578.minimum-time-to-make-rope-colorful
🏷️ Tags
#greedy #array #string #dynamic_programming
🟡1578.minimum-time-to-make-rope-colorful
🏷️ Tags
#greedy #array #string #dynamic_programming
Telegraph
minimum-time-to-make-rope-colorful
Alice has n balloons arranged on a rope. You are given a 0-indexed string colors where colors[i] is the color of the ith balloon. Alice wants the rope to be colorful. She does not want two consecutive balloons to be of the same color, so she asks Bob for…
leetcode.cn 2025-11-08
🔴1611.minimum-one-bit-operations-to-make-integers-zero
🏷️ Tags
#bit_manipulation #memoization #dynamic_programming
🔴1611.minimum-one-bit-operations-to-make-integers-zero
🏷️ Tags
#bit_manipulation #memoization #dynamic_programming
Telegraph
minimum-one-bit-operations-to-make-integers-zero
给你一个整数 n,你需要重复执行多次下述操作将其转换为 0 :
leetcode.com 2025-11-08
🔴1611.minimum-one-bit-operations-to-make-integers-zero
🏷️ Tags
#bit_manipulation #memoization #dynamic_programming
🔴1611.minimum-one-bit-operations-to-make-integers-zero
🏷️ Tags
#bit_manipulation #memoization #dynamic_programming
Telegraph
minimum-one-bit-operations-to-make-integers-zero
Given an integer n, you must transform it into 0 using the following operations any number of times:
leetcode.cn 2025-11-23
🟡1262.greatest-sum-divisible-by-three
🏷️ Tags
#greedy #array #dynamic_programming #sorting
🟡1262.greatest-sum-divisible-by-three
🏷️ Tags
#greedy #array #dynamic_programming #sorting
Telegraph
greatest-sum-divisible-by-three
给你一个整数数组 nums,请你找出并返回能被三整除的元素 最大和。 示例 1: 输入:nums = [3,6,5,1,8] 输出:18 解释:选出数字 3, 6, 1 和 8,它们的和是 18(可被 3 整除的最大和)。 示例 2: 输入:nums = [4] 输出:0 解释:4 不能被 3 整除,所以无法选出数字,返回 0。 示例 3: 输入:nums = [1,2,3,4,4] 输出:12 解释:选出数字 1, 3, 4 以及 4,它们的和是 12(可被 3 整除的最大和)。 提示:
leetcode.com 2025-11-23
🟡1262.greatest-sum-divisible-by-three
🏷️ Tags
#greedy #array #dynamic_programming #sorting
🟡1262.greatest-sum-divisible-by-three
🏷️ Tags
#greedy #array #dynamic_programming #sorting
Telegraph
greatest-sum-divisible-by-three
Given an integer array nums, return the maximum possible sum of elements of the array such that it is divisible by three. Example 1: Input: nums = [3,6,5,1,8] Output: 18 Explanation: Pick numbers 3, 6, 1 and 8 their sum is 18 (maximum sum divisible by 3).…
leetcode.cn 2025-11-26
🔴2435.paths-in-matrix-whose-sum-is-divisible-by-k
🏷️ Tags
#array #dynamic_programming #matrix
🔴2435.paths-in-matrix-whose-sum-is-divisible-by-k
🏷️ Tags
#array #dynamic_programming #matrix
Telegraph
paths-in-matrix-whose-sum-is-divisible-by-k
给你一个下标从 0 开始的 m x n 整数矩阵 grid 和一个整数 k 。你从起点 (0, 0) 出发,每一步只能往 下 或者往 右 ,你想要到达终点 (m - 1, n - 1) 。 请你返回路径和能被 k 整除的路径数目,由于答案可能很大,返回答案对 109 + 7 取余 的结果。 示例 1: 输入:grid = [[5,2,4],[3,0,5],[0,7,2]], k = 3 输出:2 解释:有两条路径满足路径上元素的和能被 k 整除。 第一条路径为上图中用红色标注的路径,和为 5 + 2…
leetcode.com 2025-11-26
🔴2435.paths-in-matrix-whose-sum-is-divisible-by-k
🏷️ Tags
#array #dynamic_programming #matrix
🔴2435.paths-in-matrix-whose-sum-is-divisible-by-k
🏷️ Tags
#array #dynamic_programming #matrix
Telegraph
paths-in-matrix-whose-sum-is-divisible-by-k
You are given a 0-indexed m x n integer matrix grid and an integer k. You are currently at position (0, 0) and you want to reach position (m - 1, n - 1) moving only down or right. Return the number of paths where the sum of the elements on the path is divisible…
leetcode.cn 2025-12-06
🟡3578.count-partitions-with-max-min-difference-at-most-k
🏷️ Tags
#queue #array #dynamic_programming #prefix_sum #sliding_window #monotonic_queue
🟡3578.count-partitions-with-max-min-difference-at-most-k
🏷️ Tags
#queue #array #dynamic_programming #prefix_sum #sliding_window #monotonic_queue
Telegraph
count-partitions-with-max-min-difference-at-most-k
给你一个整数数组 nums 和一个整数 k。你的任务是将 nums 分割成一个或多个 非空 的连续子段,使得每个子段的 最大值 与 最小值 之间的差值 不超过 k。
leetcode.com 2025-12-06
🟡3578.count-partitions-with-max-min-difference-at-most-k
🏷️ Tags
#queue #array #dynamic_programming #prefix_sum #sliding_window #monotonic_queue
🟡3578.count-partitions-with-max-min-difference-at-most-k
🏷️ Tags
#queue #array #dynamic_programming #prefix_sum #sliding_window #monotonic_queue
Telegraph
count-partitions-with-max-min-difference-at-most-k
You are given an integer array nums and an integer k. Your task is to partition nums into one or more non-empty contiguous segments such that in each segment, the difference between its maximum and minimum elements is at most k. Return the total number of…
leetcode.cn 2025-12-14
🔴2147.number-of-ways-to-divide-a-long-corridor
🏷️ Tags
#math #string #dynamic_programming
🔴2147.number-of-ways-to-divide-a-long-corridor
🏷️ Tags
#math #string #dynamic_programming
Telegraph
number-of-ways-to-divide-a-long-corridor
在一个图书馆的长廊里,有一些座位和装饰植物排成一列。给你一个下标从 0 开始,长度为 n 的字符串 corridor ,它包含字母 'S' 和 'P' ,其中每个 'S' 表示一个座位,每个 'P' 表示一株植物。 在下标 0 的左边和下标 n - 1 的右边 已经 分别各放了一个屏风。你还需要额外放置一些屏风。每一个位置 i - 1 和 i 之间(1 <= i <= n - 1),至多能放一个屏风。 请你将走廊用屏风划分为若干段,且每一段内都 恰好有两个座位 ,而每一段内植物的数目没有要求。可能有多种…
leetcode.com 2025-12-14
🔴2147.number-of-ways-to-divide-a-long-corridor
🏷️ Tags
#math #string #dynamic_programming
🔴2147.number-of-ways-to-divide-a-long-corridor
🏷️ Tags
#math #string #dynamic_programming
Telegraph
number-of-ways-to-divide-a-long-corridor
Along a long library corridor, there is a line of seats and decorative plants. You are given a 0-indexed string corridor of length n consisting of letters 'S' and 'P' where each 'S' represents a seat and each 'P' represents a plant. One room divider has already…
leetcode.cn 2025-12-15
🟡2110.number-of-smooth-descent-periods-of-a-stock
🏷️ Tags
#array #math #dynamic_programming
🟡2110.number-of-smooth-descent-periods-of-a-stock
🏷️ Tags
#array #math #dynamic_programming
Telegraph
number-of-smooth-descent-periods-of-a-stock
给你一个整数数组 prices ,表示一支股票的历史每日股价,其中 prices[i] 是这支股票第 i 天的价格。 一个 平滑下降的阶段 定义为:对于 连续一天或者多天 ,每日股价都比 前一日股价恰好少 1 ,这个阶段第一天的股价没有限制。 请你返回 平滑下降阶段 的数目。 示例 1: 输入:prices = [3,2,1,4] 输出:7 解释:总共有 7 个平滑下降阶段: [3], [2], [1], [4], [3,2], [2,1] 和 [3,2,1] 注意,仅一天按照定义也是平滑下降阶段。…
leetcode.com 2025-12-15
🟡2110.number-of-smooth-descent-periods-of-a-stock
🏷️ Tags
#array #math #dynamic_programming
🟡2110.number-of-smooth-descent-periods-of-a-stock
🏷️ Tags
#array #math #dynamic_programming
Telegraph
number-of-smooth-descent-periods-of-a-stock
You are given an integer array prices representing the daily price history of a stock, where prices[i] is the stock price on the ith day. A smooth descent period of a stock consists of one or more contiguous days such that the price on each day is lower than…
leetcode.cn 2025-12-16
🔴3562.maximum-profit-from-trading-stocks-with-discounts
🏷️ Tags
#tree #depth_first_search #array #dynamic_programming
🔴3562.maximum-profit-from-trading-stocks-with-discounts
🏷️ Tags
#tree #depth_first_search #array #dynamic_programming
Telegraph
maximum-profit-from-trading-stocks-with-discounts
给你一个整数 n,表示公司中员工的数量。每位员工都分配了一个从 1 到 n 的唯一 ID ,其中员工 1 是 CEO。另给你两个下标从 1 开始的整数数组 present 和 future,两个数组的长度均为 n,具体定义如下:
leetcode.com 2025-12-16
🔴3562.maximum-profit-from-trading-stocks-with-discounts
🏷️ Tags
#tree #depth_first_search #array #dynamic_programming
🔴3562.maximum-profit-from-trading-stocks-with-discounts
🏷️ Tags
#tree #depth_first_search #array #dynamic_programming
Telegraph
maximum-profit-from-trading-stocks-with-discounts
You are given an integer n, representing the number of employees in a company. Each employee is assigned a unique ID from 1 to n, and employee 1 is the CEO. You are given two 1-based integer arrays, present and future, each of length n, where: