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)…
leetcode.cn 2023-04-22
🟡1027.longest-arithmetic-subsequence
🏷️ Tags
#array #hash_table #binary_search #dynamic_programming
🟡1027.longest-arithmetic-subsequence
🏷️ Tags
#array #hash_table #binary_search #dynamic_programming
Telegraph
longest-arithmetic-subsequence
给你一个整数数组 nums,返回 nums 中最长等差子序列的长度。 回想一下,nums 的子序列是一个列表 nums[i1], nums[i2], ..., nums[ik] ,且 0 <= i1 < i2 < ... < ik <= nums.length - 1。并且如果 seq[i+1] - seq[i]( 0 <= i < seq.length - 1) 的值都相同,那么序列 seq 是等差的。 示例 1: 输入:nums = [3,6,9,12] 输出:4 解释: 整个数组是公差为 3 的等差数列。…
leetcode.com 2023-04-22
🔴1312.minimum-insertion-steps-to-make-a-string-palindrome
🏷️ Tags
#string #dynamic_programming
🔴1312.minimum-insertion-steps-to-make-a-string-palindrome
🏷️ Tags
#string #dynamic_programming
Telegraph
minimum-insertion-steps-to-make-a-string-palindrome
Given a string s. In one step you can insert any character at any index of the string. Return the minimum number of steps to make s palindrome. A Palindrome String is one that reads the same backward as well as forward. Example 1: Input: s = "zzazz" Output:…
leetcode.com 2023-04-25
🟡2336.smallest-number-in-infinite-set
🏷️ Tags
#design #hash_table #heap_priority_queue
🟡2336.smallest-number-in-infinite-set
🏷️ Tags
#design #hash_table #heap_priority_queue
Telegraph
smallest-number-in-infinite-set
You have a set which contains all positive integers [1, 2, 3, 4, 5, ...]. Implement the SmallestInfiniteSet class: