leetcode.com 2023-08-23
🟡767.reorganize-string
🏷️ Tags
#greedy #hash_table #string #counting #sorting #heap_priority_queue
🟡767.reorganize-string
🏷️ Tags
#greedy #hash_table #string #counting #sorting #heap_priority_queue
Telegraph
reorganize-string
Given a string s, rearrange the characters of s so that any two adjacent characters are not the same. Return any possible rearrangement of s or return "" if not possible. Example 1: Input: s = "aab" Output: "aba" Example 2: Input: s = "aaab" Output: ""…
👍1
leetcode.cn 2023-08-24
🟡1267.count-servers-that-communicate
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #counting #matrix
🟡1267.count-servers-that-communicate
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #counting #matrix
Telegraph
count-servers-that-communicate
这里有一幅服务器分布图,服务器的位置标识在 m * n 的整数矩阵网格 grid 中,1 表示单元格上有服务器,0 表示没有。 如果两台服务器位于同一行或者同一列,我们就认为它们之间可以进行通信。 请你统计并返回能够与至少一台其他服务器进行通信的服务器的数量。 示例 1: 输入:grid = [[1,0],[0,1]] 输出:0 解释:没有一台服务器能与其他服务器进行通信。 示例 2: 输入:grid = [[1,0],[1,1]] 输出:3 解释:所有这些服务器都至少可以与一台别的服务器进行通信。…
leetcode.cn 2023-08-25
🟡1448.count-good-nodes-in-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
🟡1448.count-good-nodes-in-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
count-good-nodes-in-binary-tree
给你一棵根为 root 的二叉树,请你返回二叉树中好节点的数目。 「好节点」X 定义为:从根到该节点 X 所经过的节点中,没有任何节点的值大于 X 的值。 示例 1: 输入:root = [3,1,4,3,null,1,5] 输出:4 解释:图中蓝色节点为好节点。 根节点 (3) 永远是个好节点。 节点 4 -> (3,4) 是路径中的最大值。 节点 5 -> (3,4,5) 是路径中的最大值。 节点 3 -> (3,1,3) 是路径中的最大值。 示例 2: 输入:root = [3,3,null,4…
leetcode.com 2023-08-26
🟡646.maximum-length-of-pair-chain
🏷️ Tags
#greedy #array #dynamic_programming #sorting
🟡646.maximum-length-of-pair-chain
🏷️ Tags
#greedy #array #dynamic_programming #sorting
Telegraph
maximum-length-of-pair-chain
You are given an array of n pairs pairs where pairs[i] = [lefti, righti] and lefti < righti. A pair p2 = [c, d] follows a pair p1 = [a, b] if b < c. A chain of pairs can be formed in this fashion. Return the length longest chain which can be formed. You do…
leetcode.cn 2023-08-29
🟡823.binary-trees-with-factors
🏷️ Tags
#array #hash_table #dynamic_programming #sorting
🟡823.binary-trees-with-factors
🏷️ Tags
#array #hash_table #dynamic_programming #sorting
Telegraph
binary-trees-with-factors
给出一个含有不重复整数元素的数组 arr ,每个整数 arr[i] 均大于 1。 用这些整数来构建二叉树,每个整数可以使用任意次数。其中:每个非叶结点的值应等于它的两个子结点的值的乘积。 满足条件的二叉树一共有多少个?答案可能很大,返回 对 109 + 7 取余 的结果。 示例 1: 输入: arr = [2, 4] 输出: 3 解释: 可以得到这些二叉树: [2], [4], [4, 2, 2] 示例 2: 输入: arr = [2, 4, 5, 10] 输出: 7 解释: 可以得到这些二叉树: [2]…
leetcode.cn 2023-08-30
🟡1654.minimum-jumps-to-reach-home
🏷️ Tags
#breadth_first_search #array #dynamic_programming
🟡1654.minimum-jumps-to-reach-home
🏷️ Tags
#breadth_first_search #array #dynamic_programming
Telegraph
minimum-jumps-to-reach-home
有一只跳蚤的家在数轴上的位置 x 处。请你帮助它从位置 0 出发,到达它的家。 跳蚤跳跃的规则如下:
leetcode.com 2023-08-31
🔴1326.minimum-number-of-taps-to-open-to-water-a-garden
🏷️ Tags
#greedy #array #dynamic_programming
🔴1326.minimum-number-of-taps-to-open-to-water-a-garden
🏷️ Tags
#greedy #array #dynamic_programming
Telegraph
minimum-number-of-taps-to-open-to-water-a-garden
There is a one-dimensional garden on the x-axis. The garden starts at the point 0 and ends at the point n. (i.e The length of the garden is n). There are n + 1 taps located at points [0, 1, ..., n] in the garden. Given an integer n and an integer array ranges…
leetcode.com 2023-09-02
🟡2707.extra-characters-in-a-string
🏷️ Tags
#trie #array #hash_table #string #dynamic_programming
🟡2707.extra-characters-in-a-string
🏷️ Tags
#trie #array #hash_table #string #dynamic_programming
Telegraph
extra-characters-in-a-string
You are given a 0-indexed string s and a dictionary of words dictionary. You have to break s into one or more non-overlapping substrings such that each substring is present in dictionary. There may be some extra characters in s which are not present in any…