leetcode.com 2023-07-10
🟢111.minimum-depth-of-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
🟢111.minimum-depth-of-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
minimum-depth-of-binary-tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note: A leaf is a node with no children. Example 1: Input: root = [3,9,20,null,null,15,7] Output:…
leetcode.com 2023-07-11
🟡863.all-nodes-distance-k-in-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
🟡863.all-nodes-distance-k-in-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
all-nodes-distance-k-in-binary-tree
Given the root of a binary tree, the value of a target node target, and an integer k, return an array of the values of all nodes that have a distance k from the target node. You can return the answer in any order. Example 1: Input: root = [3,5,1,6,2,0,8…
leetcode.com 2023-07-12
🟡802.find-eventual-safe-states
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort
🟡802.find-eventual-safe-states
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort
Telegraph
find-eventual-safe-states
There is a directed graph of n nodes with each node labeled from 0 to n - 1. The graph is represented by a 0-indexed 2D integer array graph where graph[i] is an integer array of nodes adjacent to node i, meaning there is an edge from node i to each node in…
leetcode.com 2023-07-13
🟡207.course-schedule
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort
🟡207.course-schedule
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort
Telegraph
course-schedule
There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi first if you want to take course ai.
leetcode.cn 2023-07-14
🟡979.distribute-coins-in-binary-tree
🏷️ Tags
#tree #depth_first_search #binary_tree
🟡979.distribute-coins-in-binary-tree
🏷️ Tags
#tree #depth_first_search #binary_tree
Telegraph
distribute-coins-in-binary-tree
给定一个有 N 个结点的二叉树的根结点 root,树中的每个结点上都对应有 node.val 枚硬币,并且总共有 N 枚硬币。 在一次移动中,我们可以选择两个相邻的结点,然后将一枚硬币从其中一个结点移动到另一个结点。(移动可以是从父结点到子结点,或者从子结点移动到父结点。)。 返回使每个结点上只有一枚硬币所需的移动次数。 示例 1: 输入:[3,0,0] 输出:2 解释:从树的根结点开始,我们将一枚硬币移到它的左子结点上,一枚硬币移到它的右子结点上。 示例 2: 输入:[0,3,0] 输出:3 解释…
leetcode.com 2023-07-14
🟡1218.longest-arithmetic-subsequence-of-given-difference
🏷️ Tags
#array #hash_table #dynamic_programming
🟡1218.longest-arithmetic-subsequence-of-given-difference
🏷️ Tags
#array #hash_table #dynamic_programming
Telegraph
longest-arithmetic-subsequence-of-given-difference
Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that the difference between adjacent elements in the subsequence equals difference. A subsequence is a sequence…
leetcode.com 2023-07-15
🔴1751.maximum-number-of-events-that-can-be-attended-ii
🏷️ Tags
#array #binary_search #dynamic_programming #sorting
🔴1751.maximum-number-of-events-that-can-be-attended-ii
🏷️ Tags
#array #binary_search #dynamic_programming #sorting
Telegraph
maximum-number-of-events-that-can-be-attended-ii
You are given an array of events where events[i] = [startDayi, endDayi, valuei]. The ith event starts at startDayi and ends at endDayi, and if you attend this event, you will receive a value of valuei. You are also given an integer k which represents the…
leetcode.cn 2023-07-16
🔴834.sum-of-distances-in-tree
🏷️ Tags
#tree #depth_first_search #graph #dynamic_programming
🔴834.sum-of-distances-in-tree
🏷️ Tags
#tree #depth_first_search #graph #dynamic_programming
Telegraph
sum-of-distances-in-tree
给定一个无向、连通的树。树中有 n 个标记为 0...n-1 的节点以及 n-1 条边 。 给定整数 n 和数组 edges , edges[i] = [ai, bi]表示树中的节点 ai 和 bi 之间有一条边。 返回长度为 n 的数组 answer ,其中 answer[i] 是树中第 i 个节点与所有其他节点之间的距离之和。 示例 1: 输入: n = 6, edges = [[0,1],[0,2],[2,3],[2,4],[2,5]] 输出: [8,12,6,10,10,10] 解释: 树如图所示。…
leetcode.com 2023-07-16
🔴1125.smallest-sufficient-team
🏷️ Tags
#bit_manipulation #array #dynamic_programming #bitmask
🔴1125.smallest-sufficient-team
🏷️ Tags
#bit_manipulation #array #dynamic_programming #bitmask
Telegraph
smallest-sufficient-team
In a project, you have a list of required skills req_skills, and a list of people. The ith person people[i] contains a list of skills that the person has. Consider a sufficient team: a set of people such that for every required skill in req_skills, there…
leetcode.cn 2023-07-18
🔴1851.minimum-interval-to-include-each-query
🏷️ Tags
#array #binary_search #sorting #line_sweep #heap_priority_queue
🔴1851.minimum-interval-to-include-each-query
🏷️ Tags
#array #binary_search #sorting #line_sweep #heap_priority_queue
Telegraph
minimum-interval-to-include-each-query
给你一个二维整数数组 intervals ,其中 intervals[i] = [lefti, righti] 表示第 i 个区间开始于 lefti 、结束于 righti(包含两侧取值,闭区间)。区间的 长度 定义为区间中包含的整数数目,更正式地表达是 righti - lefti + 1 。 再给你一个整数数组 queries 。第 j 个查询的答案是满足 lefti <= queries[j] <= righti 的 长度最小区间 i 的长度 。如果不存在这样的区间,那么答案是 -1 。 以数组形式返回对应查询的所有答案。…
leetcode.com 2023-07-19
🟡435.non-overlapping-intervals
🏷️ Tags
#greedy #array #dynamic_programming #sorting
🟡435.non-overlapping-intervals
🏷️ Tags
#greedy #array #dynamic_programming #sorting
Telegraph
non-overlapping-intervals
Given an array of intervals intervals where intervals[i] = [starti, endi], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Example 1: Input: intervals = [[1,2],[2,3],[3,4],[1,3]] Output: 1 Explanation:…