leetcode.cn 2024-01-21
🔴410.split-array-largest-sum
🏷️ Tags
#greedy #array #binary_search #dynamic_programming #prefix_sum
🔴410.split-array-largest-sum
🏷️ Tags
#greedy #array #binary_search #dynamic_programming #prefix_sum
Telegraph
split-array-largest-sum
给定一个非负整数数组 nums 和一个整数 k ,你需要将这个数组分成 k 个非空的连续子数组。 设计一个算法使得这 k 个子数组各自和的最大值最小。 示例 1: 输入:nums = [7,2,5,10,8], k = 2 输出:18 解释: 一共有四种方法将 nums 分割为 2 个子数组。 其中最好的方式是将其分为 [7,2,5] 和 [10,8] 。 因为此时这两个子数组各自的和的最大值为18,在所有情况中最小。 示例 2: 输入:nums = [1,2,3,4,5], k = 2 输出:9 示例…
leetcode.com 2024-01-23
🟡1239.maximum-length-of-a-concatenated-string-with-unique-characters
🏷️ Tags
#bit_manipulation #array #string #backtracking
🟡1239.maximum-length-of-a-concatenated-string-with-unique-characters
🏷️ Tags
#bit_manipulation #array #string #backtracking
Telegraph
maximum-length-of-a-concatenated-string-with-unique-characters
You are given an array of strings arr. A string s is formed by the concatenation of a subsequence of arr that has unique characters. Return the maximum possible length of s. A subsequence is an array that can be derived from another array by deleting some…
leetcode.com 2024-01-24
🟡1457.pseudo-palindromic-paths-in-a-binary-tree
🏷️ Tags
#bit_manipulation #tree #depth_first_search #breadth_first_search #binary_tree
🟡1457.pseudo-palindromic-paths-in-a-binary-tree
🏷️ Tags
#bit_manipulation #tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
pseudo-palindromic-paths-in-a-binary-tree
Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be pseudo-palindromic if at least one permutation of the node values in the path is a palindrome. Return the number of pseudo-palindromic paths going from the…
leetcode.cn 2024-01-26
🔴2846.minimum-edge-weight-equilibrium-queries-in-a-tree
🏷️ Tags
#tree #graph #array #strongly_connected_component
🔴2846.minimum-edge-weight-equilibrium-queries-in-a-tree
🏷️ Tags
#tree #graph #array #strongly_connected_component
Telegraph
minimum-edge-weight-equilibrium-queries-in-a-tree
现有一棵由 n 个节点组成的无向树,节点按从 0 到 n - 1 编号。给你一个整数 n 和一个长度为 n - 1 的二维整数数组 edges ,其中 edges[i] = [ui, vi, wi] 表示树中存在一条位于节点 ui 和节点 vi 之间、权重为 wi 的边。 另给你一个长度为 m 的二维整数数组 queries ,其中 queries[i] = [ai, bi] 。对于每条查询,请你找出使从 ai 到 bi 路径上每条边的权重相等所需的 最小操作次数 。在一次操作中,你可以选择树上的任意一条边,并将其权重更改为任意值。…
leetcode.com 2024-01-28
🔴1074.number-of-submatrices-that-sum-to-target
🏷️ Tags
#array #hash_table #matrix #prefix_sum
🔴1074.number-of-submatrices-that-sum-to-target
🏷️ Tags
#array #hash_table #matrix #prefix_sum
Telegraph
number-of-submatrices-that-sum-to-target
Given a matrix and a target, return the number of non-empty submatrices that sum to target. A submatrix x1, y1, x2, y2 is the set of all cells matrix[x][y] with x1 <= x <= x2 and y1 <= y <= y2. Two submatrices (x1, y1, x2, y2) and (x1', y1', x2', y2') are…
❤1👍1
leetcode.cn 2024-01-29
🔴514.freedom-trail
🏷️ Tags
#depth_first_search #breadth_first_search #string #dynamic_programming
🔴514.freedom-trail
🏷️ Tags
#depth_first_search #breadth_first_search #string #dynamic_programming
Telegraph
freedom-trail
电子游戏“辐射4”中,任务 “通向自由” 要求玩家到达名为 “Freedom Trail Ring” 的金属表盘,并使用表盘拼写特定关键词才能开门。 给定一个字符串 ring ,表示刻在外环上的编码;给定另一个字符串 key ,表示需要拼写的关键词。您需要算出能够拼写关键词中所有字符的最少步数。 最初,ring 的第一个字符与 12:00 方向对齐。您需要顺时针或逆时针旋转 ring 以使 key 的一个字符在 12:00 方向对齐,然后按下中心按钮,以此逐个拼写完 key 中的所有字符。 旋转 ring 拼出…