leetcode.com 2023-06-17
🔴1187.make-array-strictly-increasing
🏷️ Tags
#array #binary_search #dynamic_programming #sorting
🔴1187.make-array-strictly-increasing
🏷️ Tags
#array #binary_search #dynamic_programming #sorting
Telegraph
make-array-strictly-increasing
Given two integer arrays arr1 and arr2, return the minimum number of operations (possibly zero) needed to make arr1 strictly increasing. In one operation, you can choose two indices 0 <= i < arr1.length and 0 <= j < arr2.length and do the assignment arr1[i]…
leetcode.cn 2023-06-18
🟡1254.number-of-closed-islands
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #matrix
🟡1254.number-of-closed-islands
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #matrix
Telegraph
number-of-closed-islands
二维矩阵 grid 由 0 (土地)和 1 (水)组成。岛是由最大的4个方向连通的 0 组成的群,封闭岛是一个 完全 由1包围(左、上、右、下)的岛。 请返回 封闭岛屿 的数目。 示例 1: 输入:grid = [[1,1,1,1,1,1,1,0],[1,0,0,0,0,1,1,0],[1,0,1,0,1,1,1,0],[1,0,0,0,0,1,0,1],[1,1,1,1,1,1,1,0]] 输出:2 解释: 灰色区域的岛屿是封闭岛屿,因为这座岛屿完全被水域包围(即被 1 区域包围)。 示例 2: 输入:grid…
leetcode.com 2023-06-18
🔴2328.number-of-increasing-paths-in-a-grid
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort #memoization #array #dynamic_programming #matrix
🔴2328.number-of-increasing-paths-in-a-grid
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort #memoization #array #dynamic_programming #matrix
Telegraph
number-of-increasing-paths-in-a-grid
You are given an m x n integer matrix grid, where you can move from a cell to any adjacent cell in all 4 directions. Return the number of strictly increasing paths in the grid such that you can start from any cell and end at any cell. Since the answer may…
leetcode.cn 2023-06-19
🟡1262.greatest-sum-divisible-by-three
🏷️ Tags
#greedy #array #dynamic_programming #sorting
🟡1262.greatest-sum-divisible-by-three
🏷️ Tags
#greedy #array #dynamic_programming #sorting
Telegraph
greatest-sum-divisible-by-three
给你一个整数数组 nums,请你找出并返回能被三整除的元素最大和。 示例 1: 输入:nums = [3,6,5,1,8] 输出:18 解释:选出数字 3, 6, 1 和 8,它们的和是 18(可被 3 整除的最大和)。 示例 2: 输入:nums = [4] 输出:0 解释:4 不能被 3 整除,所以无法选出数字,返回 0。 示例 3: 输入:nums = [1,2,3,4,4] 输出:12 解释:选出数字 1, 3, 4 以及 4,它们的和是 12(可被 3 整除的最大和)。 提示:
leetcode.cn 2023-06-20
🔴1595.minimum-cost-to-connect-two-groups-of-points
🏷️ Tags
#bit_manipulation #array #dynamic_programming #bitmask #matrix
🔴1595.minimum-cost-to-connect-two-groups-of-points
🏷️ Tags
#bit_manipulation #array #dynamic_programming #bitmask #matrix
Telegraph
minimum-cost-to-connect-two-groups-of-points
给你两组点,其中第一组中有 size1 个点,第二组中有 size2 个点,且 size1 >= size2 。 任意两点间的连接成本 cost 由大小为 size1 x size2 矩阵给出,其中 cost[i][j] 是第一组中的点 i 和第二组中的点 j 的连接成本。如果两个组中的每个点都与另一组中的一个或多个点连接,则称这两组点是连通的。换言之,第一组中的每个点必须至少与第二组中的一个点连接,且第二组中的每个点必须至少与第一组中的一个点连接。 返回连通两组点所需的最小成本。 示例 1: 输入:cost…
leetcode.com 2023-06-21
🔴2448.minimum-cost-to-make-array-equal
🏷️ Tags
#greedy #array #binary_search #prefix_sum #sorting
🔴2448.minimum-cost-to-make-array-equal
🏷️ Tags
#greedy #array #binary_search #prefix_sum #sorting
Telegraph
minimum-cost-to-make-array-equal
You are given two 0-indexed arrays nums and cost consisting each of n positive integers. You can do the following operation any number of times:
leetcode.cn 2023-06-22
🟡面试题 16.19.pond-sizes-lcci
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #matrix
🟡面试题 16.19.pond-sizes-lcci
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #matrix
Telegraph
pond-sizes-lcci
你有一个用于表示一片土地的整数矩阵land,该矩阵中每个点的值代表对应地点的海拔高度。若值为0则表示水域。由垂直、水平或对角连接的水域为池塘。池塘的大小是指相连接的水域的个数。编写一个方法来计算矩阵中所有池塘的大小,返回值需要从小到大排序。 示例: 输入: [ [0,2,1,0], [0,1,0,1], [1,1,0,1], [0,1,0,1] ] 输出: [1,2,4] 提示: 0 < len(land) <= 1000 0 < len(land[i]) <= 1000
leetcode.com 2023-06-22
🟡714.best-time-to-buy-and-sell-stock-with-transaction-fee
🏷️ Tags
#greedy #array #dynamic_programming
🟡714.best-time-to-buy-and-sell-stock-with-transaction-fee
🏷️ Tags
#greedy #array #dynamic_programming
Telegraph
best-time-to-buy-and-sell-stock-with-transaction-fee
You are given an array prices where prices[i] is the price of a given stock on the ith day, and an integer fee representing a transaction fee. Find the maximum profit you can achieve. You may complete as many transactions as you like, but you need to pay…
leetcode.com 2023-06-23
🟡1027.longest-arithmetic-subsequence
🏷️ Tags
#array #hash_table #binary_search #dynamic_programming
🟡1027.longest-arithmetic-subsequence
🏷️ Tags
#array #hash_table #binary_search #dynamic_programming
Telegraph
longest-arithmetic-subsequence
Given an array nums of integers, return the length of the longest arithmetic subsequence in nums. Note that:
leetcode.cn 2023-06-24
🔴1659.maximize-grid-happiness
🏷️ Tags
#bit_manipulation #memoization #dynamic_programming #bitmask
🔴1659.maximize-grid-happiness
🏷️ Tags
#bit_manipulation #memoization #dynamic_programming #bitmask
Telegraph
maximize-grid-happiness
给你四个整数 m、n、introvertsCount 和 extrovertsCount 。有一个 m x n 网格,和两种类型的人:内向的人和外向的人。总共有 introvertsCount 个内向的人和 extrovertsCount 个外向的人。 请你决定网格中应当居住多少人,并为每个人分配一个网格单元。 注意,不必 让所有人都生活在网格中。 每个人的 幸福感 计算如下:
leetcode.com 2023-06-25
🔴1575.count-all-possible-routes
🏷️ Tags
#memoization #array #dynamic_programming
🔴1575.count-all-possible-routes
🏷️ Tags
#memoization #array #dynamic_programming
Telegraph
count-all-possible-routes
You are given an array of distinct positive integers locations where locations[i] represents the position of city i. You are also given integers start, finish and fuel representing the starting city, ending city, and the initial amount of fuel you have, respectively.…
leetcode.com 2023-06-26
🟡2462.total-cost-to-hire-k-workers
🏷️ Tags
#array #two_pointers #simulation #heap_priority_queue
🟡2462.total-cost-to-hire-k-workers
🏷️ Tags
#array #two_pointers #simulation #heap_priority_queue
Telegraph
total-cost-to-hire-k-workers
You are given a 0-indexed integer array costs where costs[i] is the cost of hiring the ith worker. You are also given two integers k and candidates. We want to hire exactly k workers according to the following rules:
leetcode.cn 2023-06-27
🟡1186.maximum-subarray-sum-with-one-deletion
🏷️ Tags
#array #dynamic_programming
🟡1186.maximum-subarray-sum-with-one-deletion
🏷️ Tags
#array #dynamic_programming
Telegraph
maximum-subarray-sum-with-one-deletion
给你一个整数数组,返回它的某个 非空 子数组(连续元素)在执行一次可选的删除操作后,所能得到的最大元素总和。换句话说,你可以从原数组中选出一个子数组,并可以决定要不要从中删除一个元素(只能删一次哦),(删除后)子数组中至少应当有一个元素,然后该子数组(剩下)的元素总和是所有子数组之中最大的。 注意,删除一个元素后,子数组 不能为空。 示例 1: 输入:arr = [1,-2,0,3] 输出:4 解释:我们可以选出 [1, -2, 0, 3],然后删掉 -2,这样得到 [1, 0, 3],和最大。 示例…