leetcode.cn 2025-07-19
🟡1233.remove-sub-folders-from-the-filesystem
🏷️ Tags
#depth_first_search #trie #array #string
🟡1233.remove-sub-folders-from-the-filesystem
🏷️ Tags
#depth_first_search #trie #array #string
Telegraph
remove-sub-folders-from-the-filesystem
你是一位系统管理员,手里有一份文件夹列表 folder,你的任务是要删除该列表中的所有 子文件夹,并以 任意顺序 返回剩下的文件夹。 如果文件夹 folder[i] 位于另一个文件夹 folder[j] 下,那么 folder[i] 就是 folder[j] 的 子文件夹 。folder[j] 的子文件夹必须以 folder[j] 开头,后跟一个 "/"。例如,"/a/b" 是 "/a" 的一个子文件夹,但 "/b" 不是 "/a/b/c" 的一个子文件夹。 文件夹的「路径」是由一个或多个按以下格式串联…
leetcode.com 2025-07-19
🟡1233.remove-sub-folders-from-the-filesystem
🏷️ Tags
#depth_first_search #trie #array #string
🟡1233.remove-sub-folders-from-the-filesystem
🏷️ Tags
#depth_first_search #trie #array #string
Telegraph
remove-sub-folders-from-the-filesystem
Given a list of folders folder, return the folders after removing all sub-folders in those folders. You may return the answer in any order. If a folder[i] is located within another folder[j], it is called a sub-folder of it. A sub-folder of folder[j] must…
leetcode.cn 2025-07-24
🔴2322.minimum-score-after-removals-on-a-tree
🏷️ Tags
#bit_manipulation #tree #depth_first_search #array
🔴2322.minimum-score-after-removals-on-a-tree
🏷️ Tags
#bit_manipulation #tree #depth_first_search #array
Telegraph
minimum-score-after-removals-on-a-tree
存在一棵无向连通树,树中有编号从 0 到 n - 1 的 n 个节点, 以及 n - 1 条边。 给你一个下标从 0 开始的整数数组 nums ,长度为 n ,其中 nums[i] 表示第 i 个节点的值。另给你一个二维整数数组 edges ,长度为 n - 1 ,其中 edges[i] = [ai, bi] 表示树中存在一条位于节点 ai 和 bi 之间的边。 删除树中两条 不同 的边以形成三个连通组件。对于一种删除边方案,定义如下步骤以计算其分数:
leetcode.com 2025-07-24
🔴2322.minimum-score-after-removals-on-a-tree
🏷️ Tags
#bit_manipulation #tree #depth_first_search #array
🔴2322.minimum-score-after-removals-on-a-tree
🏷️ Tags
#bit_manipulation #tree #depth_first_search #array
Telegraph
minimum-score-after-removals-on-a-tree
There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges. You are given a 0-indexed integer array nums of length n where nums[i] represents the value of the ith node. You are also given a 2D integer array edges of length…
leetcode.cn 2025-10-05
🟡417.pacific-atlantic-water-flow
🏷️ Tags
#depth_first_search #breadth_first_search #array #matrix
🟡417.pacific-atlantic-water-flow
🏷️ Tags
#depth_first_search #breadth_first_search #array #matrix
Telegraph
pacific-atlantic-water-flow
有一个 m × n 的矩形岛屿,与 太平洋 和 大西洋 相邻。 “太平洋” 处于大陆的左边界和上边界,而 “大西洋” 处于大陆的右边界和下边界。 这个岛被分割成一个由若干方形单元格组成的网格。给定一个 m x n 的整数矩阵 heights , heights[r][c] 表示坐标 (r, c) 上单元格 高于海平面的高度 。 岛上雨水较多,如果相邻单元格的高度 小于或等于 当前单元格的高度,雨水可以直接向北、南、东、西流向相邻单元格。水可以从海洋附近的任何单元格流入海洋。 返回网格坐标 result 的…
leetcode.com 2025-10-05
🟡417.pacific-atlantic-water-flow
🏷️ Tags
#depth_first_search #breadth_first_search #array #matrix
🟡417.pacific-atlantic-water-flow
🏷️ Tags
#depth_first_search #breadth_first_search #array #matrix
Telegraph
pacific-atlantic-water-flow
There is an m x n rectangular island that borders both the Pacific Ocean and Atlantic Ocean. The Pacific Ocean touches the island's left and top edges, and the Atlantic Ocean touches the island's right and bottom edges. The island is partitioned into a grid…
leetcode.cn 2025-10-06
🔴778.swim-in-rising-water
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #binary_search #matrix #heap_priority_queue
🔴778.swim-in-rising-water
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #binary_search #matrix #heap_priority_queue
Telegraph
swim-in-rising-water
在一个 n x n 的整数矩阵 grid 中,每一个方格的值 grid[i][j] 表示位置 (i, j) 的平台高度。 当开始下雨时,在时间为 t 时,水池中的水位为 t 。你可以从一个平台游向四周相邻的任意一个平台,但是前提是此时水位必须同时淹没这两个平台。假定你可以瞬间移动无限距离,也就是默认在方格内部游动是不耗时的。当然,在你游泳的时候你必须待在坐标方格里面。 你从坐标方格的左上平台 (0,0) 出发。返回 你到达坐标方格的右下平台 (n-1, n-1) 所需的最少时间 。 示例 1: 输入:…
leetcode.com 2025-10-06
🔴778.swim-in-rising-water
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #binary_search #matrix #heap_priority_queue
🔴778.swim-in-rising-water
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #binary_search #matrix #heap_priority_queue
Telegraph
swim-in-rising-water
You are given an n x n integer matrix grid where each value grid[i][j] represents the elevation at that point (i, j). It starts raining, and water gradually rises over time. At time t, the water level is t, meaning any cell with elevation less than equal…
leetcode.cn 2025-10-19
🟡1625.lexicographically-smallest-string-after-applying-operations
🏷️ Tags
#depth_first_search #breadth_first_search #string #enumeration
🟡1625.lexicographically-smallest-string-after-applying-operations
🏷️ Tags
#depth_first_search #breadth_first_search #string #enumeration
Telegraph
lexicographically-smallest-string-after-applying-operations
给你一个字符串 s 以及两个整数 a 和 b 。其中,字符串 s 的长度为偶数,且仅由数字 0 到 9 组成。 你可以在 s 上按任意顺序多次执行下面两个操作之一:
leetcode.com 2025-10-19
🟡1625.lexicographically-smallest-string-after-applying-operations
🏷️ Tags
#depth_first_search #breadth_first_search #string #enumeration
🟡1625.lexicographically-smallest-string-after-applying-operations
🏷️ Tags
#depth_first_search #breadth_first_search #string #enumeration
Telegraph
lexicographically-smallest-string-after-applying-operations
You are given a string s of even length consisting of digits from 0 to 9, and two integers a and b. You can apply either of the following two operations any number of times and in any order on s:
leetcode.cn 2025-11-06
🟡3607.power-grid-maintenance
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph #array #hash_table #ordered_set #heap_priority_queue
🟡3607.power-grid-maintenance
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph #array #hash_table #ordered_set #heap_priority_queue
Telegraph
power-grid-maintenance
给你一个整数 c,表示 c 个电站,每个电站有一个唯一标识符 id,从 1 到 c 编号。 这些电站通过 n 条 双向 电缆互相连接,表示为一个二维数组 connections,其中每个元素 connections[i] = [ui, vi] 表示电站 ui 和电站 vi 之间的连接。直接或间接连接的电站组成了一个 电网 。 最初,所有 电站均处于在线(正常运行)状态。 另给你一个二维数组 queries,其中每个查询属于以下 两种类型之一 :
leetcode.com 2025-11-06
🟡3607.power-grid-maintenance
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph #array #hash_table #ordered_set #heap_priority_queue
🟡3607.power-grid-maintenance
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph #array #hash_table #ordered_set #heap_priority_queue
Telegraph
power-grid-maintenance
You are given an integer c representing c power stations, each with a unique identifier id from 1 to c (1‑based indexing). These stations are interconnected via n bidirectional cables, represented by a 2D array connections, where each element connections[i]…
leetcode.cn 2025-11-28
🔴2872.maximum-number-of-k-divisible-components
🏷️ Tags
#tree #depth_first_search
🔴2872.maximum-number-of-k-divisible-components
🏷️ Tags
#tree #depth_first_search
Telegraph
maximum-number-of-k-divisible-components
给你一棵 n 个节点的无向树,节点编号为 0 到 n - 1 。给你整数 n 和一个长度为 n - 1 的二维整数数组 edges ,其中 edges[i] = [ai, bi] 表示树中节点 ai 和 bi 有一条边。 同时给你一个下标从 0 开始长度为 n 的整数数组 values ,其中 values[i] 是第 i 个节点的 值 。再给你一个整数 k 。 你可以从树中删除一些边,也可以一条边也不删,得到若干连通块。一个 连通块的值 定义为连通块中所有节点值之和。如果所有连通块的值都可以被 k 整除,那么我们说这是一个…
leetcode.com 2025-11-28
🔴2872.maximum-number-of-k-divisible-components
🏷️ Tags
#tree #depth_first_search
🔴2872.maximum-number-of-k-divisible-components
🏷️ Tags
#tree #depth_first_search
Telegraph
maximum-number-of-k-divisible-components
There is an undirected tree with n nodes labeled from 0 to n - 1. You are given the integer n and a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree. You are also given a…
leetcode.cn 2025-12-16
🔴3562.maximum-profit-from-trading-stocks-with-discounts
🏷️ Tags
#tree #depth_first_search #array #dynamic_programming
🔴3562.maximum-profit-from-trading-stocks-with-discounts
🏷️ Tags
#tree #depth_first_search #array #dynamic_programming
Telegraph
maximum-profit-from-trading-stocks-with-discounts
给你一个整数 n,表示公司中员工的数量。每位员工都分配了一个从 1 到 n 的唯一 ID ,其中员工 1 是 CEO。另给你两个下标从 1 开始的整数数组 present 和 future,两个数组的长度均为 n,具体定义如下:
leetcode.com 2025-12-16
🔴3562.maximum-profit-from-trading-stocks-with-discounts
🏷️ Tags
#tree #depth_first_search #array #dynamic_programming
🔴3562.maximum-profit-from-trading-stocks-with-discounts
🏷️ Tags
#tree #depth_first_search #array #dynamic_programming
Telegraph
maximum-profit-from-trading-stocks-with-discounts
You are given an integer n, representing the number of employees in a company. Each employee is assigned a unique ID from 1 to n, and employee 1 is the CEO. You are given two 1-based integer arrays, present and future, each of length n, where: