leetcode.cn 2023-04-12
🔴1147.longest-chunked-palindrome-decomposition
🏷️ Tags
#greedy #two_pointers #string #dynamic_programming #hash_function #rolling_hash
🔴1147.longest-chunked-palindrome-decomposition
🏷️ Tags
#greedy #two_pointers #string #dynamic_programming #hash_function #rolling_hash
Telegraph
longest-chunked-palindrome-decomposition
你会得到一个字符串 text 。你应该把它分成 k 个子字符串 (subtext1, subtext2,…, subtextk) ,要求满足:
leetcode.cn 2023-04-15
🟡1042.flower-planting-with-no-adjacent
🏷️ Tags
#depth_first_search #breadth_first_search #graph
🟡1042.flower-planting-with-no-adjacent
🏷️ Tags
#depth_first_search #breadth_first_search #graph
Telegraph
flower-planting-with-no-adjacent
有 n 个花园,按从 1 到 n 标记。另有数组 paths ,其中 paths[i] = [xi, yi] 描述了花园 xi 到花园 yi 的双向路径。在每个花园中,你打算种下四种花之一。 另外,所有花园 最多 有 3 条路径可以进入或离开. 你需要为每个花园选择一种花,使得通过路径相连的任何两个花园中的花的种类互不相同。 以数组形式返回 任一 可行的方案作为答案 answer,其中 answer[i] 为在第 (i+1) 个花园中种植的花的种类。花的种类用 1、2、3、4 表示。保证存在答案。 …
leetcode.com 2023-04-15
🔴2218.maximum-value-of-k-coins-from-piles
🏷️ Tags
#array #dynamic_programming #prefix_sum
🔴2218.maximum-value-of-k-coins-from-piles
🏷️ Tags
#array #dynamic_programming #prefix_sum
Telegraph
maximum-value-of-k-coins-from-piles
There are n piles of coins on a table. Each pile consists of a positive number of coins of assorted denominations. In one move, you can choose any coin on top of any pile, remove it, and add it to your wallet. Given a list piles, where piles[i] is a list…
👍1
leetcode.cn 2023-04-16
🔴1157.online-majority-element-in-subarray
🏷️ Tags
#design #binary_indexed_tree #segment_tree #array #binary_search
🔴1157.online-majority-element-in-subarray
🏷️ Tags
#design #binary_indexed_tree #segment_tree #array #binary_search
Telegraph
online-majority-element-in-subarray
设计一个数据结构,有效地找到给定子数组的 多数元素 。 子数组的 多数元素 是在子数组中出现 threshold 次数或次数以上的元素。 实现 MajorityChecker 类:
leetcode.com 2023-04-16
🔴1639.number-of-ways-to-form-a-target-string-given-a-dictionary
🏷️ Tags
#array #string #dynamic_programming
🔴1639.number-of-ways-to-form-a-target-string-given-a-dictionary
🏷️ Tags
#array #string #dynamic_programming
Telegraph
number-of-ways-to-form-a-target-string-given-a-dictionary
You are given a list of strings of the same length words and a string target. Your task is to form target using the given words under the following rules:
leetcode.cn 2023-04-18
🟡1026.maximum-difference-between-node-and-ancestor
🏷️ Tags
#tree #depth_first_search #binary_tree
🟡1026.maximum-difference-between-node-and-ancestor
🏷️ Tags
#tree #depth_first_search #binary_tree
Telegraph
maximum-difference-between-node-and-ancestor
给定二叉树的根节点 root,找出存在于 不同 节点 A 和 B 之间的最大值 V,其中 V = |A.val - B.val|,且 A 是 B 的祖先。 (如果 A 的任何子节点之一为 B,或者 A 的任何子节点是 B 的祖先,那么我们认为 A 是 B 的祖先) 示例 1: 输入:root = [8,3,10,1,6,null,14,null,null,4,7,13] 输出:7 解释: 我们有大量的节点与其祖先的差值,其中一些如下: |8 - 3| = 5 |3 - 7| = 4 |8 - 1| =…
leetcode.com 2023-04-19
🟡1372.longest-zigzag-path-in-a-binary-tree
🏷️ Tags
#tree #depth_first_search #dynamic_programming #binary_tree
🟡1372.longest-zigzag-path-in-a-binary-tree
🏷️ Tags
#tree #depth_first_search #dynamic_programming #binary_tree
Telegraph
longest-zigzag-path-in-a-binary-tree
You are given the root of a binary tree. A ZigZag path for a binary tree is defined as follow:
leetcode.cn 2023-04-20
🔴1187.make-array-strictly-increasing
🏷️ Tags
#array #binary_search #dynamic_programming #sorting
🔴1187.make-array-strictly-increasing
🏷️ Tags
#array #binary_search #dynamic_programming #sorting
Telegraph
make-array-strictly-increasing
给你两个整数数组 arr1 和 arr2,返回使 arr1 严格递增所需要的最小「操作」数(可能为 0)。 每一步「操作」中,你可以分别从 arr1 和 arr2 中各选出一个索引,分别为 i 和 j,0 <= i < arr1.length 和 0 <= j < arr2.length,然后进行赋值运算 arr1[i] = arr2[j]。 如果无法让 arr1 严格递增,请返回 -1。 示例 1: 输入:arr1 = [1,5,3,6,7], arr2 = [1,3,2,4] 输出:1 解释:用…
leetcode.com 2023-04-20
🟡662.maximum-width-of-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
🟡662.maximum-width-of-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
maximum-width-of-binary-tree
Given the root of a binary tree, return the maximum width of the given tree. The maximum width of a tree is the maximum width among all levels. The width of one level is defined as the length between the end-nodes (the leftmost and rightmost non-null nodes)…