leetcode.cn 2023-08-16
🟢2682.find-the-losers-of-the-circular-game
🏷️ Tags
#array #hash_table #simulation
🟢2682.find-the-losers-of-the-circular-game
🏷️ Tags
#array #hash_table #simulation
Telegraph
find-the-losers-of-the-circular-game
n 个朋友在玩游戏。这些朋友坐成一个圈,按 顺时针方向 从 1 到 n 编号。从第 i 个朋友的位置开始顺时针移动 1 步会到达第 (i + 1) 个朋友的位置(1 <= i < n),而从第 n 个朋友的位置开始顺时针移动 1 步会回到第 1 个朋友的位置。 游戏规则如下: 第 1 个朋友接球。
leetcode.com 2023-08-16
🔴239.sliding-window-maximum
🏷️ Tags
#queue #array #sliding_window #monotonic_queue #heap_priority_queue
🔴239.sliding-window-maximum
🏷️ Tags
#queue #array #sliding_window #monotonic_queue #heap_priority_queue
Telegraph
sliding-window-maximum
You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return…
leetcode.cn 2023-08-17
🔴1444.number-of-ways-of-cutting-a-pizza
🏷️ Tags
#memoization #array #dynamic_programming #matrix
🔴1444.number-of-ways-of-cutting-a-pizza
🏷️ Tags
#memoization #array #dynamic_programming #matrix
Telegraph
number-of-ways-of-cutting-a-pizza
给你一个 rows x cols 大小的矩形披萨和一个整数 k ,矩形包含两种字符: 'A' (表示苹果)和 '.' (表示空白格子)。你需要切披萨 k-1 次,得到 k 块披萨并送给别人。 切披萨的每一刀,先要选择是向垂直还是水平方向切,再在矩形的边界上选一个切的位置,将披萨一分为二。如果垂直地切披萨,那么需要把左边的部分送给一个人,如果水平地切,那么需要把上面的部分送给一个人。在切完最后一刀后,需要把剩下来的一块送给最后一个人。 请你返回确保每一块披萨包含 至少 一个苹果的切披萨方案数。由于答案可能是个很大的数字,请你返回它对…
leetcode.com 2023-08-17
🟡542.01-matrix
🏷️ Tags
#breadth_first_search #array #dynamic_programming #matrix
🟡542.01-matrix
🏷️ Tags
#breadth_first_search #array #dynamic_programming #matrix
Telegraph
01-matrix
Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1. Example 1: Input: mat = [[0,0,0],[0,1,0],[0,0,0]] Output: [[0,0,0],[0,1,0],[0,0,0]] Example 2: Input: mat = [[0,0,0],[0,1…
leetcode.cn 2023-08-18
🔴1388.pizza-with-3n-slices
🏷️ Tags
#greedy #array #dynamic_programming #heap_priority_queue
🔴1388.pizza-with-3n-slices
🏷️ Tags
#greedy #array #dynamic_programming #heap_priority_queue
Telegraph
pizza-with-3n-slices
给你一个披萨,它由 3n 块不同大小的部分组成,现在你和你的朋友们需要按照如下规则来分披萨:
leetcode.com 2023-08-19
🔴1489.find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree
🏷️ Tags
#union_find #graph #minimum_spanning_tree #sorting #strongly_connected_component
🔴1489.find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree
🏷️ Tags
#union_find #graph #minimum_spanning_tree #sorting #strongly_connected_component
Telegraph
find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree
Given a weighted undirected connected graph with n vertices numbered from 0 to n - 1, and an array edges where edges[i] = [ai, bi, weighti] represents a bidirectional and weighted edge between nodes ai and bi. A minimum spanning tree (MST) is a subset of…
leetcode.com 2023-08-20
🔴1203.sort-items-by-groups-respecting-dependencies
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort
🔴1203.sort-items-by-groups-respecting-dependencies
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort
Telegraph
sort-items-by-groups-respecting-dependencies
There are n items each belonging to zero or one of m groups where group[i] is the group that the i-th item belongs to and it's equal to -1 if the i-th item belongs to no group. The items and the groups are zero indexed. A group can have no item belonging…
leetcode.com 2023-08-23
🟡767.reorganize-string
🏷️ Tags
#greedy #hash_table #string #counting #sorting #heap_priority_queue
🟡767.reorganize-string
🏷️ Tags
#greedy #hash_table #string #counting #sorting #heap_priority_queue
Telegraph
reorganize-string
Given a string s, rearrange the characters of s so that any two adjacent characters are not the same. Return any possible rearrangement of s or return "" if not possible. Example 1: Input: s = "aab" Output: "aba" Example 2: Input: s = "aaab" Output: ""…
👍1
leetcode.cn 2023-08-24
🟡1267.count-servers-that-communicate
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #counting #matrix
🟡1267.count-servers-that-communicate
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #counting #matrix
Telegraph
count-servers-that-communicate
这里有一幅服务器分布图,服务器的位置标识在 m * n 的整数矩阵网格 grid 中,1 表示单元格上有服务器,0 表示没有。 如果两台服务器位于同一行或者同一列,我们就认为它们之间可以进行通信。 请你统计并返回能够与至少一台其他服务器进行通信的服务器的数量。 示例 1: 输入:grid = [[1,0],[0,1]] 输出:0 解释:没有一台服务器能与其他服务器进行通信。 示例 2: 输入:grid = [[1,0],[1,1]] 输出:3 解释:所有这些服务器都至少可以与一台别的服务器进行通信。…
leetcode.cn 2023-08-25
🟡1448.count-good-nodes-in-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
🟡1448.count-good-nodes-in-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
count-good-nodes-in-binary-tree
给你一棵根为 root 的二叉树,请你返回二叉树中好节点的数目。 「好节点」X 定义为:从根到该节点 X 所经过的节点中,没有任何节点的值大于 X 的值。 示例 1: 输入:root = [3,1,4,3,null,1,5] 输出:4 解释:图中蓝色节点为好节点。 根节点 (3) 永远是个好节点。 节点 4 -> (3,4) 是路径中的最大值。 节点 5 -> (3,4,5) 是路径中的最大值。 节点 3 -> (3,1,3) 是路径中的最大值。 示例 2: 输入:root = [3,3,null,4…