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…
leetcode.com 2023-09-21
🔴4.median-of-two-sorted-arrays
🏷️ Tags
#array #binary_search #divide_and_conquer
🔴4.median-of-two-sorted-arrays
🏷️ Tags
#array #binary_search #divide_and_conquer
Telegraph
median-of-two-sorted-arrays
Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example 1: Input: nums1 = [1,3], nums2 = [2] Output: 2.00000 Explanation: merged array…
leetcode.cn 2023-09-23
🟡1993.operations-on-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #design #hash_table
🟡1993.operations-on-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #design #hash_table
Telegraph
operations-on-tree
给你一棵 n 个节点的树,编号从 0 到 n - 1 ,以父节点数组 parent 的形式给出,其中 parent[i] 是第 i 个节点的父节点。树的根节点为 0 号节点,所以 parent[0] = -1 ,因为它没有父节点。你想要设计一个数据结构实现树里面对节点的加锁,解锁和升级操作。 数据结构需要支持如下函数: