leetcode.cn 2023-06-04
🟢2465.number-of-distinct-averages
🏷️ Tags
#array #hash_table #two_pointers #sorting
🟢2465.number-of-distinct-averages
🏷️ Tags
#array #hash_table #two_pointers #sorting
Telegraph
number-of-distinct-averages
给你一个下标从 0 开始长度为 偶数 的整数数组 nums 。 只要 nums 不是 空数组,你就重复执行以下步骤:
leetcode.cn 2023-06-08
🔴1240.tiling-a-rectangle-with-the-fewest-squares
🏷️ Tags
#dynamic_programming #backtracking
🔴1240.tiling-a-rectangle-with-the-fewest-squares
🏷️ Tags
#dynamic_programming #backtracking
Telegraph
tiling-a-rectangle-with-the-fewest-squares
你是一位施工队的工长,根据设计师的要求准备为一套设计风格独特的房子进行室内装修。 房子的客厅大小为 n x m,为保持极简的风格,需要使用尽可能少的 正方形 瓷砖来铺盖地面。 假设正方形瓷砖的规格不限,边长都是整数。 请你帮设计师计算一下,最少需要用到多少块方形瓷砖? 示例 1: 输入:n = 2, m = 3 输出:3 解释:3 块地砖就可以铺满卧室。 2 块 1x1 地砖 1 块 2x2 地砖 示例 2: 输入:n = 5, m = 8 输出:5 示例 3: 输入:n = 11, m = 13 输出:6…
leetcode.com 2023-06-08
🟢1351.count-negative-numbers-in-a-sorted-matrix
🏷️ Tags
#array #binary_search #matrix
🟢1351.count-negative-numbers-in-a-sorted-matrix
🏷️ Tags
#array #binary_search #matrix
Telegraph
count-negative-numbers-in-a-sorted-matrix
Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid. Example 1: Input: grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]] Output: 8 Explanation: There are 8…
leetcode.cn 2023-06-09
🔴2699.modify-graph-edge-weights
🏷️ Tags
#graph #shortest_path #heap_priority_queue
🔴2699.modify-graph-edge-weights
🏷️ Tags
#graph #shortest_path #heap_priority_queue
Telegraph
modify-graph-edge-weights
给你一个 n 个节点的 无向带权连通 图,节点编号为 0 到 n - 1 ,再给你一个整数数组 edges ,其中 edges[i] = [ai, bi, wi] 表示节点 ai 和 bi 之间有一条边权为 wi 的边。 部分边的边权为 -1(wi = -1),其他边的边权都为 正 数(wi > 0)。 你需要将所有边权为 -1 的边都修改为范围 [1, 2 * 109] 中的 正整数 ,使得从节点 source 到节点 destination 的 最短距离 为整数 target 。如果有 多种 修改方案可以使 source…
leetcode.cn 2023-06-10
🟡1170.compare-strings-by-frequency-of-the-smallest-character
🏷️ Tags
#array #hash_table #string #binary_search #sorting
🟡1170.compare-strings-by-frequency-of-the-smallest-character
🏷️ Tags
#array #hash_table #string #binary_search #sorting
Telegraph
compare-strings-by-frequency-of-the-smallest-character
定义一个函数 f(s),统计 s 中(按字典序比较)最小字母的出现频次 ,其中 s 是一个非空字符串。 例如,若 s = "dcce",那么 f(s) = 2,因为字典序最小字母是 "c",它出现了 2 次。 现在,给你两个字符串数组待查表 queries 和词汇表 words 。对于每次查询 queries[i] ,需统计 words 中满足 f(queries[i]) < f(W) 的 词的数目 ,W 表示词汇表 words 中的每个词。 请你返回一个整数数组 answer 作为答案,其中每个 answer[i] 是第…
leetcode.com 2023-06-10
🟡1802.maximum-value-at-a-given-index-in-a-bounded-array
🏷️ Tags
#greedy #binary_search
🟡1802.maximum-value-at-a-given-index-in-a-bounded-array
🏷️ Tags
#greedy #binary_search
Telegraph
maximum-value-at-a-given-index-in-a-bounded-array
You are given three positive integers: n, index, and maxSum. You want to construct an array nums (0-indexed) that satisfies the following conditions:
leetcode.cn 2023-06-11
🟡1171.remove-zero-sum-consecutive-nodes-from-linked-list
🏷️ Tags
#hash_table #linked_list
🟡1171.remove-zero-sum-consecutive-nodes-from-linked-list
🏷️ Tags
#hash_table #linked_list
Telegraph
remove-zero-sum-consecutive-nodes-from-linked-list
给你一个链表的头节点 head,请你编写代码,反复删去链表中由 总和 值为 0 的连续节点组成的序列,直到不存在这样的序列为止。 删除完毕后,请你返回最终结果链表的头节点。 你可以返回任何满足题目要求的答案。 (注意,下面示例中的所有序列,都是对 ListNode 对象序列化的表示。) 示例 1: 输入:head = [1,2,-3,3,1] 输出:[3,1] 提示:答案 [1,2,1] 也是正确的。 示例 2: 输入:head = [1,2,3,-3,4] 输出:[1,2,4] 示例 3: 输入:head…
leetcode.cn 2023-06-12
🔴1483.kth-ancestor-of-a-tree-node
🏷️ Tags
#tree #depth_first_search #breadth_first_search #design #binary_search #dynamic_programming
🔴1483.kth-ancestor-of-a-tree-node
🏷️ Tags
#tree #depth_first_search #breadth_first_search #design #binary_search #dynamic_programming
Telegraph
kth-ancestor-of-a-tree-node
给你一棵树,树上有 n 个节点,按从 0 到 n-1 编号。树以父节点数组的形式给出,其中 parent[i] 是节点 i 的父节点。树的根节点是编号为 0 的节点。 树节点的第 k 个祖先节点是从该节点到根节点路径上的第 k 个节点。 实现 TreeAncestor 类:
leetcode.com 2023-06-13
🟡2352.equal-row-and-column-pairs
🏷️ Tags
#array #hash_table #matrix #simulation
🟡2352.equal-row-and-column-pairs
🏷️ Tags
#array #hash_table #matrix #simulation
Telegraph
equal-row-and-column-pairs
Given a 0-indexed n x n integer matrix grid, return the number of pairs (ri, cj) such that row ri and column cj are equal. A row and column pair is considered equal if they contain the same elements in the same order (i.e., an equal array). Example 1: Input:…