leetcode.cn 2023-11-09
🔴2258.escape-the-spreading-fire
🏷️ Tags
#breadth_first_search #array #binary_search #matrix
🔴2258.escape-the-spreading-fire
🏷️ Tags
#breadth_first_search #array #binary_search #matrix
Telegraph
escape-the-spreading-fire
给你一个下标从 0 开始大小为 m x n 的二维整数数组 grid ,它表示一个网格图。每个格子为下面 3 个值之一:
leetcode.cn 2023-11-10
🟡2300.successful-pairs-of-spells-and-potions
🏷️ Tags
#array #two_pointers #binary_search #sorting
🟡2300.successful-pairs-of-spells-and-potions
🏷️ Tags
#array #two_pointers #binary_search #sorting
Telegraph
successful-pairs-of-spells-and-potions
给你两个正整数数组 spells 和 potions ,长度分别为 n 和 m ,其中 spells[i] 表示第 i 个咒语的能量强度,potions[j] 表示第 j 瓶药水的能量强度。 同时给你一个整数 success 。一个咒语和药水的能量强度 相乘 如果 大于等于 success ,那么它们视为一对 成功 的组合。 请你返回一个长度为 n 的整数数组 pairs,其中 pairs[i] 是能跟第 i 个咒语成功组合的 药水 数目。 示例 1: 输入:spells = [5,1,3], potions…
leetcode.cn 2023-11-11
🔴765.couples-holding-hands
🏷️ Tags
#greedy #depth_first_search #breadth_first_search #union_find #graph
🔴765.couples-holding-hands
🏷️ Tags
#greedy #depth_first_search #breadth_first_search #union_find #graph
Telegraph
couples-holding-hands
n 对情侣坐在连续排列的 2n 个座位上,想要牵到对方的手。 人和座位由一个整数数组 row 表示,其中 row[i] 是坐在第 i 个座位上的人的 ID。情侣们按顺序编号,第一对是 (0, 1),第二对是 (2, 3),以此类推,最后一对是 (2n-2, 2n-1)。 返回 最少交换座位的次数,以便每对情侣可以并肩坐在一起。 每次交换可选择任意两人,让他们站起来交换座位。 示例 1: 输入: row = [0,2,1,3] 输出: 1 解释: 只需要交换row[1]和row[2]的位置即可。 示例…
leetcode.com 2023-11-11
🔴2642.design-graph-with-shortest-path-calculator
🏷️ Tags
#graph #design #shortest_path #heap_priority_queue
🔴2642.design-graph-with-shortest-path-calculator
🏷️ Tags
#graph #design #shortest_path #heap_priority_queue
Telegraph
design-graph-with-shortest-path-calculator
There is a directed weighted graph that consists of n nodes numbered from 0 to n - 1. The edges of the graph are initially represented by the given array edges where edges[i] = [fromi, toi, edgeCosti] meaning that there is an edge from fromi to toi with the…
leetcode.cn 2023-11-13
🟡307.range-sum-query-mutable
🏷️ Tags
#design #binary_indexed_tree #segment_tree #array
🟡307.range-sum-query-mutable
🏷️ Tags
#design #binary_indexed_tree #segment_tree #array
Telegraph
range-sum-query-mutable
给你一个数组 nums ,请你完成两类查询。
leetcode.cn 2023-11-14
🟡1334.find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance
🏷️ Tags
#graph #dynamic_programming #shortest_path
🟡1334.find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance
🏷️ Tags
#graph #dynamic_programming #shortest_path
Telegraph
find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance
有 n 个城市,按从 0 到 n-1 编号。给你一个边数组 edges,其中 edges[i] = [fromi, toi, weighti] 代表 fromi 和 toi 两个城市之间的双向加权边,距离阈值是一个整数 distanceThreshold。 返回能通过某些路径到达其他城市数目最少、且路径距离 最大 为 distanceThreshold 的城市。如果有多个这样的城市,则返回编号最大的城市。 注意,连接城市 i 和 j 的路径的距离等于沿该路径的所有边的权重之和。 示例 1: 输入:n…
👍1
leetcode.com 2023-11-14
🟡1930.unique-length-3-palindromic-subsequences
🏷️ Tags
#hash_table #string #prefix_sum
🟡1930.unique-length-3-palindromic-subsequences
🏷️ Tags
#hash_table #string #prefix_sum
Telegraph
unique-length-3-palindromic-subsequences
Given a string s, return the number of unique palindromes of length three that are a subsequence of s. Note that even if there are multiple ways to obtain the same subsequence, it is still only counted once. A palindrome is a string that reads the same forwards…
leetcode.com 2023-11-15
🟡1846.maximum-element-after-decreasing-and-rearranging
🏷️ Tags
#greedy #array #sorting
🟡1846.maximum-element-after-decreasing-and-rearranging
🏷️ Tags
#greedy #array #sorting
Telegraph
maximum-element-after-decreasing-and-rearranging
You are given an array of positive integers arr. Perform some operations (possibly none) on arr so that it satisfies these conditions: