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:
leetcode.com 2023-06-30
🔴1970.last-day-where-you-can-still-cross
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #binary_search #matrix
🔴1970.last-day-where-you-can-still-cross
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #binary_search #matrix
Telegraph
last-day-where-you-can-still-cross
There is a 1-based binary matrix where 0 represents land and 1 represents water. You are given integers row and col representing the number of rows and columns in the matrix, respectively. Initially on day 0, the entire matrix is land. However, each day a…
leetcode.com 2023-07-01
🟡2305.fair-distribution-of-cookies
🏷️ Tags
#bit_manipulation #array #dynamic_programming #backtracking #bitmask
🟡2305.fair-distribution-of-cookies
🏷️ Tags
#bit_manipulation #array #dynamic_programming #backtracking #bitmask
Telegraph
fair-distribution-of-cookies
You are given an integer array cookies, where cookies[i] denotes the number of cookies in the ith bag. You are also given an integer k that denotes the number of children to distribute all the bags of cookies to. All the cookies in the same bag must go to…
leetcode.com 2023-07-02
🔴1601.maximum-number-of-achievable-transfer-requests
🏷️ Tags
#bit_manipulation #array #backtracking #enumeration
🔴1601.maximum-number-of-achievable-transfer-requests
🏷️ Tags
#bit_manipulation #array #backtracking #enumeration
Telegraph
maximum-number-of-achievable-transfer-requests
We have n buildings numbered from 0 to n - 1. Each building has a number of employees. It's transfer season, and some employees want to change the building they reside in. You are given an array requests where requests[i] = [fromi, toi] represents an employee's…