leetcode.com 2023-10-15
🔴1269.number-of-ways-to-stay-in-the-same-place-after-some-steps
🏷️ Tags
#dynamic_programming
🔴1269.number-of-ways-to-stay-in-the-same-place-after-some-steps
🏷️ Tags
#dynamic_programming
Telegraph
number-of-ways-to-stay-in-the-same-place-after-some-steps
You have a pointer at index 0 in an array of size arrLen. At each step, you can move 1 position to the left, 1 position to the right in the array, or stay in the same place (The pointer should not be placed outside the array at any time). Given two integers…
leetcode.com 2023-10-17
🟡1361.validate-binary-tree-nodes
🏷️ Tags
#tree #depth_first_search #breadth_first_search #union_find #graph #binary_tree
🟡1361.validate-binary-tree-nodes
🏷️ Tags
#tree #depth_first_search #breadth_first_search #union_find #graph #binary_tree
Telegraph
validate-binary-tree-nodes
You have n binary tree nodes numbered from 0 to n - 1 where node i has two children leftChild[i] and rightChild[i], return true if and only if all the given nodes form exactly one valid binary tree. If node i has no left child then leftChild[i] will equal…
leetcode.cn 2023-10-18
🟡2530.maximal-score-after-applying-k-operations
🏷️ Tags
#greedy #array #heap_priority_queue
🟡2530.maximal-score-after-applying-k-operations
🏷️ Tags
#greedy #array #heap_priority_queue
Telegraph
maximal-score-after-applying-k-operations
给你一个下标从 0 开始的整数数组 nums 和一个整数 k 。你的 起始分数 为 0 。 在一步 操作 中:
leetcode.com 2023-10-18
🔴2050.parallel-courses-iii
🏷️ Tags
#graph #topological_sort #array #dynamic_programming
🔴2050.parallel-courses-iii
🏷️ Tags
#graph #topological_sort #array #dynamic_programming
Telegraph
parallel-courses-iii
You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given a 2D integer array relations where relations[j] = [prevCoursej, nextCoursej] denotes that course prevCoursej has to be completed before course nextCoursej…
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…