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:
leetcode.cn 2023-04-26
🟡1031.maximum-sum-of-two-non-overlapping-subarrays
🏷️ Tags
#array #dynamic_programming #sliding_window
🟡1031.maximum-sum-of-two-non-overlapping-subarrays
🏷️ Tags
#array #dynamic_programming #sliding_window
Telegraph
maximum-sum-of-two-non-overlapping-subarrays
给你一个整数数组 nums 和两个整数 firstLen 和 secondLen,请你找出并返回两个非重叠 子数组 中元素的最大和,长度分别为 firstLen 和 secondLen 。 长度为 firstLen 的子数组可以出现在长为 secondLen 的子数组之前或之后,但二者必须是不重叠的。 子数组是数组的一个 连续 部分。 示例 1: 输入:nums = [0,6,5,2,2,5,1,9,4], firstLen = 1, secondLen = 2 输出:20 解释:子数组的一种选择中,[9]…
leetcode.cn 2023-04-28
🔴1172.dinner-plate-stacks
🏷️ Tags
#stack #design #hash_table #heap_priority_queue
🔴1172.dinner-plate-stacks
🏷️ Tags
#stack #design #hash_table #heap_priority_queue
Telegraph
dinner-plate-stacks
我们把无限数量 ∞ 的栈排成一行,按从左到右的次序从 0 开始编号。每个栈的的最大容量 capacity 都相同。 实现一个叫「餐盘」的类 DinnerPlates: