leetcode.cn 2025-11-21
🟡1930.unique-length-3-palindromic-subsequences
🏷️ Tags
#bit_manipulation #hash_table #string #prefix_sum
🟡1930.unique-length-3-palindromic-subsequences
🏷️ Tags
#bit_manipulation #hash_table #string #prefix_sum
Telegraph
unique-length-3-palindromic-subsequences
给你一个字符串 s ,返回 s 中 长度为 3 的不同回文子序列 的个数。 即便存在多种方法来构建相同的子序列,但相同的子序列只计数一次。 回文 是正着读和反着读一样的字符串。 子序列 是由原字符串删除其中部分字符(也可以不删除)且不改变剩余字符之间相对顺序形成的一个新字符串。
leetcode.com 2025-11-21
🟡1930.unique-length-3-palindromic-subsequences
🏷️ Tags
#bit_manipulation #hash_table #string #prefix_sum
🟡1930.unique-length-3-palindromic-subsequences
🏷️ Tags
#bit_manipulation #hash_table #string #prefix_sum
Telegraph
unique-length-3-palindromic-subsequences
Given a string s, return the number of unique palindromes of length three that are a subsequence of s. Note that even if there are multiple ways to obtain the same subsequence, it is still only counted once. A palindrome is a string that reads the same forwards…
leetcode.cn 2025-11-22
🟢3190.find-minimum-operations-to-make-all-elements-divisible-by-three
🏷️ Tags
#array #math
🟢3190.find-minimum-operations-to-make-all-elements-divisible-by-three
🏷️ Tags
#array #math
Telegraph
find-minimum-operations-to-make-all-elements-divisible-by-three
给你一个整数数组 nums 。一次操作中,你可以将 nums 中的 任意 一个元素增加或者减少 1 。 请你返回将 nums 中所有元素都可以被 3 整除的 最少 操作次数。 示例 1: 输入:nums = [1,2,3,4] 输出:3 解释: 通过以下 3 个操作,数组中的所有元素都可以被 3 整除:
leetcode.com 2025-11-22
🟢3190.find-minimum-operations-to-make-all-elements-divisible-by-three
🏷️ Tags
#array #math
🟢3190.find-minimum-operations-to-make-all-elements-divisible-by-three
🏷️ Tags
#array #math
Telegraph
find-minimum-operations-to-make-all-elements-divisible-by-three
You are given an integer array nums. In one operation, you can add or subtract 1 from any element of nums. Return the minimum number of operations to make all elements of nums divisible by 3. Example 1: Input: nums = [1,2,3,4] Output: 3 Explanation: All…
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-11-27
🟡3381.maximum-subarray-sum-with-length-divisible-by-k
🏷️ Tags
#array #hash_table #prefix_sum
🟡3381.maximum-subarray-sum-with-length-divisible-by-k
🏷️ Tags
#array #hash_table #prefix_sum
Telegraph
maximum-subarray-sum-with-length-divisible-by-k
给你一个整数数组 nums 和一个整数 k 。
leetcode.com 2025-11-27
🟡3381.maximum-subarray-sum-with-length-divisible-by-k
🏷️ Tags
#array #hash_table #prefix_sum
🟡3381.maximum-subarray-sum-with-length-divisible-by-k
🏷️ Tags
#array #hash_table #prefix_sum
Telegraph
maximum-subarray-sum-with-length-divisible-by-k
You are given an array of integers nums and an integer k. Return the maximum sum of a subarray of nums, such that the size of the subarray is divisible by k. Example 1: Input: nums = [1,2], k = 1 Output: 3 Explanation: The subarray [1, 2] with sum 3 has…
leetcode.cn 2025-11-28
🔴2872.maximum-number-of-k-divisible-components
🏷️ Tags
#tree #depth_first_search
🔴2872.maximum-number-of-k-divisible-components
🏷️ Tags
#tree #depth_first_search
Telegraph
maximum-number-of-k-divisible-components
给你一棵 n 个节点的无向树,节点编号为 0 到 n - 1 。给你整数 n 和一个长度为 n - 1 的二维整数数组 edges ,其中 edges[i] = [ai, bi] 表示树中节点 ai 和 bi 有一条边。 同时给你一个下标从 0 开始长度为 n 的整数数组 values ,其中 values[i] 是第 i 个节点的 值 。再给你一个整数 k 。 你可以从树中删除一些边,也可以一条边也不删,得到若干连通块。一个 连通块的值 定义为连通块中所有节点值之和。如果所有连通块的值都可以被 k 整除,那么我们说这是一个…
leetcode.com 2025-11-28
🔴2872.maximum-number-of-k-divisible-components
🏷️ Tags
#tree #depth_first_search
🔴2872.maximum-number-of-k-divisible-components
🏷️ Tags
#tree #depth_first_search
Telegraph
maximum-number-of-k-divisible-components
There is an undirected tree with n nodes labeled from 0 to n - 1. You are given the integer n and a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree. You are also given a…
leetcode.cn 2025-12-01
🔴2141.maximum-running-time-of-n-computers
🏷️ Tags
#greedy #array #binary_search #sorting
🔴2141.maximum-running-time-of-n-computers
🏷️ Tags
#greedy #array #binary_search #sorting
Telegraph
maximum-running-time-of-n-computers
你有 n 台电脑。给你整数 n 和一个下标从 0 开始的整数数组 batteries ,其中第 i 个电池可以让一台电脑 运行 batteries[i] 分钟。你想使用这些电池让 全部 n 台电脑 同时 运行。 一开始,你可以给每台电脑连接 至多一个电池 。然后在任意整数时刻,你都可以将一台电脑与它的电池断开连接,并连接另一个电池,你可以进行这个操作 任意次 。新连接的电池可以是一个全新的电池,也可以是别的电脑用过的电池。断开连接和连接新的电池不会花费任何时间。 注意,你不能给电池充电。 请你返回你可以让…