leetcode.com 2026-10-09
🟡1541.minimum-insertions-to-balance-a-parentheses-string
🏷️ Tags
#stack #greedy #string #bracket_sequences
🟡1541.minimum-insertions-to-balance-a-parentheses-string
🏷️ Tags
#stack #greedy #string #bracket_sequences
Telegraph
minimum-insertions-to-balance-a-parentheses-string
Given a parentheses string s containing only the characters '(' and ')'. A parentheses string is balanced if:
leetcode.cn 2026-10-29
🔴3841.palindromic-path-queries-in-a-tree
🏷️ Tags
#bit_manipulation #tree #depth_first_search #binary_indexed_tree #segment_tree #array #string #divide_and_conquer
🔴3841.palindromic-path-queries-in-a-tree
🏷️ Tags
#bit_manipulation #tree #depth_first_search #binary_indexed_tree #segment_tree #array #string #divide_and_conquer
Telegraph
palindromic-path-queries-in-a-tree
给你一棵包含 n 个节点的无向树,节点编号从 0 到 n - 1。树由一个长度为 n - 1 的二维数组 edges 表示,其中 edges[i] = [ui, vi] 表示节点 ui 和 vi 之间存在一条无向边。
leetcode.com 2026-10-29
🔴3841.palindromic-path-queries-in-a-tree
🏷️ Tags
#bit_manipulation #tree #depth_first_search #binary_indexed_tree #segment_tree #array #string #divide_and_conquer
🔴3841.palindromic-path-queries-in-a-tree
🏷️ Tags
#bit_manipulation #tree #depth_first_search #binary_indexed_tree #segment_tree #array #string #divide_and_conquer
Telegraph
palindromic-path-queries-in-a-tree
You are given an undirected tree with n nodes labeled 0 to n - 1. This is represented by a 2D array edges of length n - 1, where edges[i] = [ui, vi] indicates an undirected edge between nodes ui and vi. You are also given a string s of length n consisting…
leetcode.cn 2026-10-30
🟡3970.shortest-path-with-at-most-k-consecutive-identical-characters
🏷️ Tags
#graph #string #shortest_path #heap_priority_queue
🟡3970.shortest-path-with-at-most-k-consecutive-identical-characters
🏷️ Tags
#graph #string #shortest_path #heap_priority_queue
Telegraph
shortest-path-with-at-most-k-consecutive-identical-characters
给你一个整数 n,表示一个 有向加权 图中的节点数量,节点编号从 0 到 n - 1。该图由二维数组 edges 表示,其中 edges[i] = [ui, vi, wi] 表示一条从节点 ui 指向节点 vi、权重为 wi 的有向边。
leetcode.com 2026-10-30
🟡3970.shortest-path-with-at-most-k-consecutive-identical-characters
🏷️ Tags
#graph #string #shortest_path #heap_priority_queue
🟡3970.shortest-path-with-at-most-k-consecutive-identical-characters
🏷️ Tags
#graph #string #shortest_path #heap_priority_queue
Telegraph
shortest-path-with-at-most-k-consecutive-identical-characters
You are given an integer n representing the number of nodes in a directed weighted graph, numbered from 0 to n - 1. This is represented by a 2D integer array edges, where edges[i] = [ui, vi, wi] represents a directed edge from node ui to node vi with weight…
leetcode.cn 2026-11-17
🔴2911.minimum-changes-to-make-k-semi-palindromes
🏷️ Tags
#two_pointers #string #dynamic_programming
🔴2911.minimum-changes-to-make-k-semi-palindromes
🏷️ Tags
#two_pointers #string #dynamic_programming
Telegraph
minimum-changes-to-make-k-semi-palindromes
给你一个字符串 s 和一个整数 k,请将 s 划分为 k 个 非空子串 ,使得将每个子串变为 半回文串 所需的字符修改次数之和最小。 返回所需的 最少 字符修改次数。 半回文串 是一类特殊的字符串:它可以按照某种重复模式拆分后,使每一组都成为 回文串 。判断一个字符串是否为半回文串的方法如下:
leetcode.com 2026-11-17
🔴2911.minimum-changes-to-make-k-semi-palindromes
🏷️ Tags
#two_pointers #string #dynamic_programming
🔴2911.minimum-changes-to-make-k-semi-palindromes
🏷️ Tags
#two_pointers #string #dynamic_programming
Telegraph
minimum-changes-to-make-k-semi-palindromes
Given a string s and an integer k, partition s into k substrings such that the letter changes needed to make each substring a semi-palindrome are minimized. Return the minimum number of letter changes required. A semi-palindrome is a special type of string…
leetcode.com 2026-11-18
🟡2914.minimum-number-of-changes-to-make-binary-string-beautiful
🏷️ Tags
#string
🟡2914.minimum-number-of-changes-to-make-binary-string-beautiful
🏷️ Tags
#string
Telegraph
minimum-number-of-changes-to-make-binary-string-beautiful
You are given a 0-indexed binary string s having an even length. A string is beautiful if it's possible to partition it into one or more substrings such that:
leetcode.cn 2026-11-21
🟡3331.find-subtree-sizes-after-changes
🏷️ Tags
#tree #depth_first_search #array #hash_table #string
🟡3331.find-subtree-sizes-after-changes
🏷️ Tags
#tree #depth_first_search #array #hash_table #string
Telegraph
find-subtree-sizes-after-changes
给你一棵 n 个节点且根节点为编号 0 的树,节点编号为 0 到 n - 1 。这棵树用一个长度为 n 的数组 parent 表示,其中 parent[i] 是第 i 个节点的父亲节点的编号。由于节点 0 是根,parent[0] == -1 。 给你一个长度为 n 的字符串 s ,其中 s[i] 是节点 i 对应的字符。 对于节点编号从 1 到 n - 1 的每个节点 x ,我们 同时 执行以下操作 一次 :
leetcode.com 2026-11-21
🟡3331.find-subtree-sizes-after-changes
🏷️ Tags
#tree #depth_first_search #array #hash_table #string
🟡3331.find-subtree-sizes-after-changes
🏷️ Tags
#tree #depth_first_search #array #hash_table #string
Telegraph
find-subtree-sizes-after-changes
You are given a tree rooted at node 0 that consists of n nodes numbered from 0 to n - 1. The tree is represented by an array parent of size n, where parent[i] is the parent of node i. Since node 0 is the root, parent[0] == -1. You are also given a string…
leetcode.cn 2026-12-02
🟡1202.smallest-string-with-swaps
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #hash_table #string #sorting
🟡1202.smallest-string-with-swaps
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #hash_table #string #sorting
Telegraph
smallest-string-with-swaps
给你一个字符串 s,以及该字符串中的一些「索引对」数组 pairs,其中 pairs[i] = [a, b] 表示字符串中的两个索引(编号从 0 开始)。 你可以 任意多次交换 在 pairs 中任意一对索引处的字符。 返回在经过若干次交换后,s 可以变成的按字典序最小的字符串。 示例 1: 输入:s = "dcab", pairs = [[0,3],[1,2]] 输出:"bacd" 解释: 交换 s[0] 和 s[3], s = "bcad" 交换 s[1] 和 s[2], s = "bacd" 示例…