leetcode.com 2023-09-10
🔴1359.count-all-valid-pickup-and-delivery-options
🏷️ Tags
#math #dynamic_programming #combinatorics
🔴1359.count-all-valid-pickup-and-delivery-options
🏷️ Tags
#math #dynamic_programming #combinatorics
Telegraph
count-all-valid-pickup-and-delivery-options
Given n orders, each order consist in pickup and delivery services. Count all valid pickup/delivery possible sequences such that delivery(i) is always after of pickup(i). Since the answer may be too large, return it modulo 10^9 + 7. Example 1: Input:…
leetcode.com 2023-09-11
🟡1282.group-the-people-given-the-group-size-they-belong-to
🏷️ Tags
#array #hash_table
🟡1282.group-the-people-given-the-group-size-they-belong-to
🏷️ Tags
#array #hash_table
Telegraph
group-the-people-given-the-group-size-they-belong-to
There are n people that are split into some unknown number of groups. Each person is labeled with a unique ID from 0 to n - 1. You are given an integer array groupSizes, where groupSizes[i] is the size of the group that person i is in. For example, if groupSizes[1]…
leetcode.com 2023-09-12
🟡1647.minimum-deletions-to-make-character-frequencies-unique
🏷️ Tags
#greedy #hash_table #string #sorting
🟡1647.minimum-deletions-to-make-character-frequencies-unique
🏷️ Tags
#greedy #hash_table #string #sorting
Telegraph
minimum-deletions-to-make-character-frequencies-unique
A string s is called good if there are no two different characters in s that have the same frequency. Given a string s, return the minimum number of characters you need to delete to make s good. The frequency of a character in a string is the number of times…
leetcode.cn 2023-09-13
🟡2596.check-knight-tour-configuration
🏷️ Tags
#depth_first_search #breadth_first_search #array #matrix #simulation
🟡2596.check-knight-tour-configuration
🏷️ Tags
#depth_first_search #breadth_first_search #array #matrix #simulation
Telegraph
check-knight-tour-configuration
骑士在一张 n x n 的棋盘上巡视。在有效的巡视方案中,骑士会从棋盘的 左上角 出发,并且访问棋盘上的每个格子 恰好一次 。 给你一个 n x n 的整数矩阵 grid ,由范围 [0, n * n - 1] 内的不同整数组成,其中 grid[row][col] 表示单元格 (row, col) 是骑士访问的第 grid[row][col] 个单元格。骑士的行动是从下标 0 开始的。 如果 grid 表示了骑士的有效巡视方案,返回 true;否则返回 false。 注意,骑士行动时可以垂直移动两个格子…
leetcode.com 2023-09-14
🔴332.reconstruct-itinerary
🏷️ Tags
#depth_first_search #graph #eulerian_circuit
🔴332.reconstruct-itinerary
🏷️ Tags
#depth_first_search #graph #eulerian_circuit
Telegraph
reconstruct-itinerary
You are given a list of airline tickets where tickets[i] = [fromi, toi] represent the departure and the arrival airports of one flight. Reconstruct the itinerary in order and return it. All of the tickets belong to a man who departs from "JFK", thus, the…
leetcode.com 2023-09-15
🟡1584.min-cost-to-connect-all-points
🏷️ Tags
#union_find #graph #array #minimum_spanning_tree
🟡1584.min-cost-to-connect-all-points
🏷️ Tags
#union_find #graph #array #minimum_spanning_tree
Telegraph
min-cost-to-connect-all-points
You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi]. The cost of connecting two points [xi, yi] and [xj, yj] is the manhattan distance between them: |xi - xj| + |yi - yj|, where |val| denotes…
leetcode.com 2023-09-16
🟡1631.path-with-minimum-effort
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #binary_search #matrix #heap_priority_queue
🟡1631.path-with-minimum-effort
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #binary_search #matrix #heap_priority_queue
Telegraph
path-with-minimum-effort
You are a hiker preparing for an upcoming hike. You are given heights, a 2D array of size rows x columns, where heights[row][col] represents the height of cell (row, col). You are situated in the top-left cell, (0, 0), and you hope to travel to the bottom…
leetcode.com 2023-09-17
🔴847.shortest-path-visiting-all-nodes
🏷️ Tags
#bit_manipulation #breadth_first_search #graph #dynamic_programming #bitmask
🔴847.shortest-path-visiting-all-nodes
🏷️ Tags
#bit_manipulation #breadth_first_search #graph #dynamic_programming #bitmask
Telegraph
shortest-path-visiting-all-nodes
You have an undirected, connected graph of n nodes labeled from 0 to n - 1. You are given an array graph where graph[i] is a list of all the nodes connected with node i by an edge. Return the length of the shortest path that visits every node. You may start…
leetcode.cn 2023-09-18
🟡337.house-robber-iii
🏷️ Tags
#tree #depth_first_search #dynamic_programming #binary_tree
🟡337.house-robber-iii
🏷️ Tags
#tree #depth_first_search #dynamic_programming #binary_tree
Telegraph
house-robber-iii
小偷又发现了一个新的可行窃的地区。这个地区只有一个入口,我们称之为 root 。 除了 root 之外,每栋房子有且只有一个“父“房子与之相连。一番侦察之后,聪明的小偷意识到“这个地方的所有房屋的排列类似于一棵二叉树”。 如果 两个直接相连的房子在同一天晚上被打劫 ,房屋将自动报警。 给定二叉树的 root 。返回 在不触动警报的情况下 ,小偷能够盗取的最高金额 。 示例 1: 输入: root = [3,2,3,null,3,null,1] 输出: 7 解释: 小偷一晚能够盗取的最高金额 3 + 3…
leetcode.com 2023-09-18
🟢1337.the-k-weakest-rows-in-a-matrix
🏷️ Tags
#array #binary_search #matrix #sorting #heap_priority_queue
🟢1337.the-k-weakest-rows-in-a-matrix
🏷️ Tags
#array #binary_search #matrix #sorting #heap_priority_queue
Telegraph
the-k-weakest-rows-in-a-matrix
You are given an m x n binary matrix mat of 1's (representing soldiers) and 0's (representing civilians). The soldiers are positioned in front of the civilians. That is, all the 1's will appear to the left of all the 0's in each row. A row i is weaker than…
leetcode.com 2023-09-19
🟡287.find-the-duplicate-number
🏷️ Tags
#bit_manipulation #array #two_pointers #binary_search
🟡287.find-the-duplicate-number
🏷️ Tags
#bit_manipulation #array #two_pointers #binary_search
Telegraph
find-the-duplicate-number
Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive. There is only one repeated number in nums, return this repeated number. You must solve the problem without modifying the array nums and uses only…
leetcode.com 2023-09-20
🟡1658.minimum-operations-to-reduce-x-to-zero
🏷️ Tags
#array #hash_table #binary_search #prefix_sum #sliding_window
🟡1658.minimum-operations-to-reduce-x-to-zero
🏷️ Tags
#array #hash_table #binary_search #prefix_sum #sliding_window
Telegraph
minimum-operations-to-reduce-x-to-zero
You are given an integer array nums and an integer x. In one operation, you can either remove the leftmost or the rightmost element from the array nums and subtract its value from x. Note that this modifies the array for future operations. Return the minimum…