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],和最大。 示例…
leetcode.cn 2023-06-28
🔴1681.minimum-incompatibility
🏷️ Tags
#bit_manipulation #array #dynamic_programming #bitmask
🔴1681.minimum-incompatibility
🏷️ Tags
#bit_manipulation #array #dynamic_programming #bitmask
Telegraph
minimum-incompatibility
给你一个整数数组 nums 和一个整数 k 。你需要将这个数组划分到 k 个相同大小的子集中,使得同一个子集里面没有两个相同的元素。 一个子集的 不兼容性 是该子集里面最大值和最小值的差。 请你返回将数组分成 k 个子集后,各子集 不兼容性 的 和 的 最小值 ,如果无法分成分成 k 个子集,返回 -1 。 子集的定义是数组中一些数字的集合,对数字顺序没有要求。 示例 1: 输入:nums = [1,2,1,4], k = 2 输出:4 解释:最优的分配是 [1,2] 和 [1,4] 。 不兼容性和为…
leetcode.com 2023-06-28
🟡1514.path-with-maximum-probability
🏷️ Tags
#graph #array #shortest_path #heap_priority_queue
🟡1514.path-with-maximum-probability
🏷️ Tags
#graph #array #shortest_path #heap_priority_queue
Telegraph
path-with-maximum-probability
You are given an undirected weighted graph of n nodes (0-indexed), represented by an edge list where edges[i] = [a, b] is an undirected edge connecting the nodes a and b with a probability of success of traversing that edge succProb[i]. Given two nodes start and end…
leetcode.com 2023-06-29
🔴864.shortest-path-to-get-all-keys
🏷️ Tags
#bit_manipulation #breadth_first_search #array #matrix
🔴864.shortest-path-to-get-all-keys
🏷️ Tags
#bit_manipulation #breadth_first_search #array #matrix
Telegraph
shortest-path-to-get-all-keys
You are given an m x n grid grid where: