leetcode.com 2023-07-06
🟡209.minimum-size-subarray-sum
🏷️ Tags
#array #binary_search #prefix_sum #sliding_window
🟡209.minimum-size-subarray-sum
🏷️ Tags
#array #binary_search #prefix_sum #sliding_window
Telegraph
minimum-size-subarray-sum
Given an array of positive integers nums and a positive integer target, return the minimal length of a subarray whose sum is greater than or equal to target. If there is no such subarray, return 0 instead. Example 1: Input: target = 7, nums = [2,3,1,2,4…
leetcode.com 2023-07-07
🟡2024.maximize-the-confusion-of-an-exam
🏷️ Tags
#string #binary_search #prefix_sum #sliding_window
🟡2024.maximize-the-confusion-of-an-exam
🏷️ Tags
#string #binary_search #prefix_sum #sliding_window
Telegraph
maximize-the-confusion-of-an-exam
A teacher is writing a test with n true/false questions, with 'T' denoting true and 'F' denoting false. He wants to confuse the students by maximizing the number of consecutive questions with the same answer (multiple trues or multiple falses in a row). You…
leetcode.cn 2023-07-08
🟡167.two-sum-ii-input-array-is-sorted
🏷️ Tags
#array #two_pointers #binary_search
🟡167.two-sum-ii-input-array-is-sorted
🏷️ Tags
#array #two_pointers #binary_search
Telegraph
two-sum-ii-input-array-is-sorted
给你一个下标从 1 开始的整数数组 numbers ,该数组已按 非递减顺序排列 ,请你从数组中找出满足相加之和等于目标数 target 的两个数。如果设这两个数分别是 numbers[index1] 和 numbers[index2] ,则 1 <= index1 < index2 <= numbers.length 。 以长度为 2 的整数数组 [index1, index2] 的形式返回这两个整数的下标 index1 和 index2。 你可以假设每个输入 只对应唯一的答案 ,而且你 不可以 重复使用相同的元素。…
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…