leetcode.cn 2025-03-20
🔴2612.minimum-reverse-operations
🏷️ Tags
#breadth_first_search #array #ordered_set
🔴2612.minimum-reverse-operations
🏷️ Tags
#breadth_first_search #array #ordered_set
Telegraph
minimum-reverse-operations
给你一个整数 n 和一个在范围 [0, n - 1] 以内的整数 p ,它们表示一个长度为 n 且下标从 0 开始的数组 arr ,数组中除了下标为 p 处是 1 以外,其他所有数都是 0 。 同时给你一个整数数组 banned ,它包含数组中的一些位置。banned 中第 i 个位置表示 arr[banned[i]] = 0 ,题目保证 banned[i] != p 。 你可以对 arr 进行 若干次 操作。一次操作中,你选择大小为 k 的一个 子数组 ,并将它 翻转 。在任何一次翻转操作后,你都需要确保…
leetcode.com 2025-03-20
🔴3108.minimum-cost-walk-in-weighted-graph
🏷️ Tags
#bit_manipulation #union_find #graph #array
🔴3108.minimum-cost-walk-in-weighted-graph
🏷️ Tags
#bit_manipulation #union_find #graph #array
Telegraph
minimum-cost-walk-in-weighted-graph
There is an undirected weighted graph with n vertices labeled from 0 to n - 1. You are given the integer n and an array edges, where edges[i] = [ui, vi, wi] indicates that there is an edge between vertices ui and vi with a weight of wi. A walk on a graph…
👍1
leetcode.com 2025-03-21
🟡2115.find-all-possible-recipes-from-given-supplies
🏷️ Tags
#graph #topological_sort #array #hash_table #string
🟡2115.find-all-possible-recipes-from-given-supplies
🏷️ Tags
#graph #topological_sort #array #hash_table #string
Telegraph
find-all-possible-recipes-from-given-supplies
You have information about n different recipes. You are given a string array recipes and a 2D string array ingredients. The ith recipe has the name recipes[i], and you can create it if you have all the needed ingredients from ingredients[i]. A recipe can…
leetcode.com 2025-03-22
🟡2685.count-the-number-of-complete-components
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph
🟡2685.count-the-number-of-complete-components
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph
Telegraph
count-the-number-of-complete-components
You are given an integer n. There is an undirected graph with n vertices, numbered from 0 to n - 1. You are given a 2D integer array edges where edges[i] = [ai, bi] denotes that there exists an undirected edge connecting vertices ai and bi. Return the number…
leetcode.cn 2025-03-25
🟡2711.difference-of-number-of-distinct-values-on-diagonals
🏷️ Tags
#array #hash_table #matrix
🟡2711.difference-of-number-of-distinct-values-on-diagonals
🏷️ Tags
#array #hash_table #matrix
Telegraph
difference-of-number-of-distinct-values-on-diagonals
给你一个下标从 0 开始、大小为 m x n 的二维矩阵 grid ,请你求解大小同样为 m x n 的答案矩阵 answer 。 矩阵 answer 中每个单元格 (r, c) 的值可以按下述方式进行计算:
leetcode.com 2025-03-26
🟡2033.minimum-operations-to-make-a-uni-value-grid
🏷️ Tags
#array #math #matrix #sorting
🟡2033.minimum-operations-to-make-a-uni-value-grid
🏷️ Tags
#array #math #matrix #sorting
Telegraph
minimum-operations-to-make-a-uni-value-grid
You are given a 2D integer grid of size m x n and an integer x. In one operation, you can add x to or subtract x from any element in the grid. A uni-value grid is a grid where all the elements of it are equal. Return the minimum number of operations to make…
leetcode.cn 2025-03-27
🟡2712.minimum-cost-to-make-all-characters-equal
🏷️ Tags
#greedy #string #dynamic_programming
🟡2712.minimum-cost-to-make-all-characters-equal
🏷️ Tags
#greedy #string #dynamic_programming
Telegraph
minimum-cost-to-make-all-characters-equal
给你一个下标从 0 开始、长度为 n 的二进制字符串 s ,你可以对其执行两种操作:
leetcode.com 2025-03-28
🔴2503.maximum-number-of-points-from-grid-queries
🏷️ Tags
#breadth_first_search #union_find #array #two_pointers #matrix #sorting #heap_priority_queue
🔴2503.maximum-number-of-points-from-grid-queries
🏷️ Tags
#breadth_first_search #union_find #array #two_pointers #matrix #sorting #heap_priority_queue
Telegraph
maximum-number-of-points-from-grid-queries
You are given an m x n integer matrix grid and an array queries of size k. Find an array answer of size k such that for each integer queries[i] you start in the top left cell of the matrix and repeat the following process:
leetcode.cn 2025-03-29
🔴2360.longest-cycle-in-a-graph
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort
🔴2360.longest-cycle-in-a-graph
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort
Telegraph
longest-cycle-in-a-graph
给你一个 n 个节点的 有向图 ,节点编号为 0 到 n - 1 ,其中每个节点 至多 有一条出边。 图用一个大小为 n 下标从 0 开始的数组 edges 表示,节点 i 到节点 edges[i] 之间有一条有向边。如果节点 i 没有出边,那么 edges[i] == -1 。 请你返回图中的 最长 环,如果没有任何环,请返回 -1 。 一个环指的是起点和终点是 同一个 节点的路径。 示例 1: 输入:edges = [3,3,4,2,3] 输出去:3 解释:图中的最长环是:2 -> 4 -> 3…
leetcode.com 2025-03-29
🔴2818.apply-operations-to-maximize-score
🏷️ Tags
#stack #greedy #array #math #number_theory #sorting #monotonic_stack
🔴2818.apply-operations-to-maximize-score
🏷️ Tags
#stack #greedy #array #math #number_theory #sorting #monotonic_stack
Telegraph
apply-operations-to-maximize-score
You are given an array nums of n positive integers and an integer k. Initially, you start with a score of 1. You have to maximize your score by applying the following operation at most k times:
leetcode.cn 2025-03-30
🟡2109.adding-spaces-to-a-string
🏷️ Tags
#array #two_pointers #string #simulation
🟡2109.adding-spaces-to-a-string
🏷️ Tags
#array #two_pointers #string #simulation
Telegraph
adding-spaces-to-a-string
给你一个下标从 0 开始的字符串 s ,以及一个下标从 0 开始的整数数组 spaces 。 数组 spaces 描述原字符串中需要添加空格的下标。每个空格都应该插入到给定索引处的字符值 之前 。