leetcode.com 2023-10-20
🟡341.flatten-nested-list-iterator
🏷️ Tags
#stack #tree #depth_first_search #design #queue #iterator
🟡341.flatten-nested-list-iterator
🏷️ Tags
#stack #tree #depth_first_search #design #queue #iterator
Telegraph
flatten-nested-list-iterator
You are given a nested list of integers nestedList. Each element is either an integer or a list whose elements may also be integers or other lists. Implement an iterator to flatten it. Implement the NestedIterator class:
leetcode.cn 2023-10-21
🟡2316.count-unreachable-pairs-of-nodes-in-an-undirected-graph
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph
🟡2316.count-unreachable-pairs-of-nodes-in-an-undirected-graph
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph
Telegraph
count-unreachable-pairs-of-nodes-in-an-undirected-graph
给你一个整数 n ,表示一张 无向图 中有 n 个节点,编号为 0 到 n - 1 。同时给你一个二维整数数组 edges ,其中 edges[i] = [ai, bi] 表示节点 ai 和 bi 之间有一条 无向 边。 请你返回 无法互相到达 的不同 点对数目 。 示例 1: 输入:n = 3, edges = [[0,1],[0,2],[1,2]] 输出:0 解释:所有点都能互相到达,意味着没有点对无法互相到达,所以我们返回 0 。 示例 2: 输入:n = 7, edges = [[0,2],[0…
leetcode.com 2023-10-21
🔴1425.constrained-subsequence-sum
🏷️ Tags
#queue #array #dynamic_programming #sliding_window #monotonic_queue #heap_priority_queue
🔴1425.constrained-subsequence-sum
🏷️ Tags
#queue #array #dynamic_programming #sliding_window #monotonic_queue #heap_priority_queue
Telegraph
constrained-subsequence-sum
Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence, nums[i] and nums[j], where i < j, the condition j - i <= k is satisfied. A subsequence…
leetcode.com 2023-10-22
🔴1793.maximum-score-of-a-good-subarray
🏷️ Tags
#stack #array #two_pointers #binary_search #monotonic_stack
🔴1793.maximum-score-of-a-good-subarray
🏷️ Tags
#stack #array #two_pointers #binary_search #monotonic_stack
Telegraph
maximum-score-of-a-good-subarray
You are given an array of integers nums (0-indexed) and an integer k. The score of a subarray (i, j) is defined as min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1). A good subarray is a subarray where i <= k <= j. Return the maximum possible score of a…
leetcode.com 2023-10-24
🟡515.find-largest-value-in-each-tree-row
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
🟡515.find-largest-value-in-each-tree-row
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
find-largest-value-in-each-tree-row
Given the root of a binary tree, return an array of the largest value in each row of the tree (0-indexed). Example 1: Input: root = [1,3,2,5,3,null,9] Output: [1,3,9] Example 2: Input: root = [1,2,3] Output: [1,3] Constraints:
leetcode.com 2023-10-26
🟡823.binary-trees-with-factors
🏷️ Tags
#array #hash_table #dynamic_programming #sorting
🟡823.binary-trees-with-factors
🏷️ Tags
#array #hash_table #dynamic_programming #sorting
Telegraph
binary-trees-with-factors
Given an array of unique integers, arr, where each integer arr[i] is strictly greater than 1. We make a binary tree using these integers, and each number may be used for any number of times. Each non-leaf node's value should be equal to the product of the…
leetcode.cn 2023-10-27
🟡1465.maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts
🏷️ Tags
#greedy #array #sorting
🟡1465.maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts
🏷️ Tags
#greedy #array #sorting
Telegraph
maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts
矩形蛋糕的高度为 h 且宽度为 w,给你两个整数数组 horizontalCuts 和 verticalCuts,其中:
leetcode.cn 2023-10-28
🟢2558.take-gifts-from-the-richest-pile
🏷️ Tags
#array #simulation #heap_priority_queue
🟢2558.take-gifts-from-the-richest-pile
🏷️ Tags
#array #simulation #heap_priority_queue
Telegraph
take-gifts-from-the-richest-pile
给你一个整数数组 gifts ,表示各堆礼物的数量。每一秒,你需要执行以下操作: