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 描述原字符串中需要添加空格的下标。每个空格都应该插入到给定索引处的字符值 之前 。
leetcode.cn 2025-04-04
🟡1123.lowest-common-ancestor-of-deepest-leaves
🏷️ Tags
#tree #depth_first_search #breadth_first_search #hash_table #binary_tree
🟡1123.lowest-common-ancestor-of-deepest-leaves
🏷️ Tags
#tree #depth_first_search #breadth_first_search #hash_table #binary_tree
Telegraph
lowest-common-ancestor-of-deepest-leaves
给你一个有根节点 root 的二叉树,返回它 最深的叶节点的最近公共祖先 。 回想一下:
leetcode.com 2025-04-04
🟡1123.lowest-common-ancestor-of-deepest-leaves
🏷️ Tags
#tree #depth_first_search #breadth_first_search #hash_table #binary_tree
🟡1123.lowest-common-ancestor-of-deepest-leaves
🏷️ Tags
#tree #depth_first_search #breadth_first_search #hash_table #binary_tree
Telegraph
lowest-common-ancestor-of-deepest-leaves
Given the root of a binary tree, return the lowest common ancestor of its deepest leaves. Recall that:
leetcode.cn 2025-04-05
🟢1863.sum-of-all-subset-xor-totals
🏷️ Tags
#bit_manipulation #array #math #backtracking #combinatorics #enumeration
🟢1863.sum-of-all-subset-xor-totals
🏷️ Tags
#bit_manipulation #array #math #backtracking #combinatorics #enumeration
Telegraph
sum-of-all-subset-xor-totals
一个数组的 异或总和 定义为数组中所有元素按位 XOR 的结果;如果数组为 空 ,则异或总和为 0 。
leetcode.com 2025-04-05
🟢1863.sum-of-all-subset-xor-totals
🏷️ Tags
#bit_manipulation #array #math #backtracking #combinatorics #enumeration
🟢1863.sum-of-all-subset-xor-totals
🏷️ Tags
#bit_manipulation #array #math #backtracking #combinatorics #enumeration
Telegraph
sum-of-all-subset-xor-totals
The XOR total of an array is defined as the bitwise XOR of all its elements, or 0 if the array is empty.
leetcode.cn 2025-04-06
🟡368.largest-divisible-subset
🏷️ Tags
#array #math #dynamic_programming #sorting
🟡368.largest-divisible-subset
🏷️ Tags
#array #math #dynamic_programming #sorting
Telegraph
largest-divisible-subset
answer[i] % answer[j] == 0 ,或