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 描述原字符串中需要添加空格的下标。每个空格都应该插入到给定索引处的字符值 之前 。