diff --git a/solution/3300-3399/3375.Minimum Operations to Make Array Values Equal to K/README.md b/solution/3300-3399/3375.Minimum Operations to Make Array Values Equal to K/README.md index db42c4a72a6d0..903476925539b 100644 --- a/solution/3300-3399/3375.Minimum Operations to Make Array Values Equal to K/README.md +++ b/solution/3300-3399/3375.Minimum Operations to Make Array Values Equal to K/README.md @@ -2,6 +2,9 @@ comments: true difficulty: 简单 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3375.Minimum%20Operations%20to%20Make%20Array%20Values%20Equal%20to%20K/README.md +tags: + - 数组 + - 哈希表 --- diff --git a/solution/3300-3399/3375.Minimum Operations to Make Array Values Equal to K/README_EN.md b/solution/3300-3399/3375.Minimum Operations to Make Array Values Equal to K/README_EN.md index 03d07597f5a11..49b0d5a025aa5 100644 --- a/solution/3300-3399/3375.Minimum Operations to Make Array Values Equal to K/README_EN.md +++ b/solution/3300-3399/3375.Minimum Operations to Make Array Values Equal to K/README_EN.md @@ -2,6 +2,9 @@ comments: true difficulty: Easy edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3375.Minimum%20Operations%20to%20Make%20Array%20Values%20Equal%20to%20K/README_EN.md +tags: + - Array + - Hash Table --- diff --git a/solution/3300-3399/3376.Minimum Time to Break Locks I/README.md b/solution/3300-3399/3376.Minimum Time to Break Locks I/README.md index 41f59a87c72d2..01b8b2a873838 100644 --- a/solution/3300-3399/3376.Minimum Time to Break Locks I/README.md +++ b/solution/3300-3399/3376.Minimum Time to Break Locks I/README.md @@ -2,6 +2,12 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3376.Minimum%20Time%20to%20Break%20Locks%20I/README.md +tags: + - 位运算 + - 数组 + - 动态规划 + - 回溯 + - 状态压缩 --- diff --git a/solution/3300-3399/3376.Minimum Time to Break Locks I/README_EN.md b/solution/3300-3399/3376.Minimum Time to Break Locks I/README_EN.md index 8460e4e8fe4e2..40b0897fafd8c 100644 --- a/solution/3300-3399/3376.Minimum Time to Break Locks I/README_EN.md +++ b/solution/3300-3399/3376.Minimum Time to Break Locks I/README_EN.md @@ -2,6 +2,12 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3376.Minimum%20Time%20to%20Break%20Locks%20I/README_EN.md +tags: + - Bit Manipulation + - Array + - Dynamic Programming + - Backtracking + - Bitmask --- diff --git a/solution/3300-3399/3377.Digit Operations to Make Two Integers Equal/README.md b/solution/3300-3399/3377.Digit Operations to Make Two Integers Equal/README.md index 01ee143b2770b..e71a030a391f8 100644 --- a/solution/3300-3399/3377.Digit Operations to Make Two Integers Equal/README.md +++ b/solution/3300-3399/3377.Digit Operations to Make Two Integers Equal/README.md @@ -2,6 +2,12 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3377.Digit%20Operations%20to%20Make%20Two%20Integers%20Equal/README.md +tags: + - 图 + - 数学 + - 数论 + - 最短路 + - 堆(优先队列) --- diff --git a/solution/3300-3399/3377.Digit Operations to Make Two Integers Equal/README_EN.md b/solution/3300-3399/3377.Digit Operations to Make Two Integers Equal/README_EN.md index 45f9bf34f0233..5ea0feed44037 100644 --- a/solution/3300-3399/3377.Digit Operations to Make Two Integers Equal/README_EN.md +++ b/solution/3300-3399/3377.Digit Operations to Make Two Integers Equal/README_EN.md @@ -2,6 +2,12 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3377.Digit%20Operations%20to%20Make%20Two%20Integers%20Equal/README_EN.md +tags: + - Graph + - Math + - Number Theory + - Shortest Path + - Heap (Priority Queue) --- diff --git a/solution/3300-3399/3378.Count Connected Components in LCM Graph/README.md b/solution/3300-3399/3378.Count Connected Components in LCM Graph/README.md index 7bf8ed0c93333..8ed252dc659f3 100644 --- a/solution/3300-3399/3378.Count Connected Components in LCM Graph/README.md +++ b/solution/3300-3399/3378.Count Connected Components in LCM Graph/README.md @@ -2,6 +2,12 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3378.Count%20Connected%20Components%20in%20LCM%20Graph/README.md +tags: + - 并查集 + - 数组 + - 哈希表 + - 数学 + - 数论 --- diff --git a/solution/3300-3399/3378.Count Connected Components in LCM Graph/README_EN.md b/solution/3300-3399/3378.Count Connected Components in LCM Graph/README_EN.md index bb65e85e33213..49412220e7194 100644 --- a/solution/3300-3399/3378.Count Connected Components in LCM Graph/README_EN.md +++ b/solution/3300-3399/3378.Count Connected Components in LCM Graph/README_EN.md @@ -2,6 +2,12 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3378.Count%20Connected%20Components%20in%20LCM%20Graph/README_EN.md +tags: + - Union Find + - Array + - Hash Table + - Math + - Number Theory --- diff --git a/solution/3300-3399/3379.Transformed Array/README.md b/solution/3300-3399/3379.Transformed Array/README.md index c59b8ab64bd64..3d5ebda765449 100644 --- a/solution/3300-3399/3379.Transformed Array/README.md +++ b/solution/3300-3399/3379.Transformed Array/README.md @@ -2,6 +2,9 @@ comments: true difficulty: 简单 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3379.Transformed%20Array/README.md +tags: + - 数组 + - 模拟 --- diff --git a/solution/3300-3399/3379.Transformed Array/README_EN.md b/solution/3300-3399/3379.Transformed Array/README_EN.md index fda2bc4dd3e98..1df8a0f3e83eb 100644 --- a/solution/3300-3399/3379.Transformed Array/README_EN.md +++ b/solution/3300-3399/3379.Transformed Array/README_EN.md @@ -2,6 +2,9 @@ comments: true difficulty: Easy edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3379.Transformed%20Array/README_EN.md +tags: + - Array + - Simulation --- diff --git a/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/README.md b/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/README.md index b2beb3081a627..e9bea7d126e49 100644 --- a/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/README.md +++ b/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/README.md @@ -2,6 +2,14 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3380.Maximum%20Area%20Rectangle%20With%20Point%20Constraints%20I/README.md +tags: + - 树状数组 + - 线段树 + - 几何 + - 数组 + - 数学 + - 枚举 + - 排序 --- @@ -87,32 +95,189 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3380.Ma -### 方法一 +### 方法一:枚举 + +我们可以枚举矩形的左下角下标 $(x_3, y_3)$ 和右上角下标 $(x_4, y_4)$,然后枚举所有的点 $(x, y)$,判断点是否在矩形的内部或边界上,如果是,说明不满足条件,否则,我们排除掉在矩形外部的点,然后判断剩下的点是否有 4 个,如果有,说明这 4 个点可以构成一个矩形,计算矩形的面积,取最大值即可。 + +时间复杂度 $O(n^3)$,其中 $n$ 是数组 $\textit{points}$ 的长度。空间复杂度 $O(1)$。 #### Python3 ```python - +class Solution: + def maxRectangleArea(self, points: List[List[int]]) -> int: + def check(x1: int, y1: int, x2: int, y2: int) -> bool: + cnt = 0 + for x, y in points: + if x < x1 or x > x2 or y < y1 or y > y2: + continue + if (x == x1 or x == x2) and (y == y1 or y == y2): + cnt += 1 + continue + return False + return cnt == 4 + + ans = -1 + for i, (x1, y1) in enumerate(points): + for x2, y2 in points[:i]: + x3, y3 = min(x1, x2), min(y1, y2) + x4, y4 = max(x1, x2), max(y1, y2) + if check(x3, y3, x4, y4): + ans = max(ans, (x4 - x3) * (y4 - y3)) + return ans ``` #### Java ```java - +class Solution { + public int maxRectangleArea(int[][] points) { + int ans = -1; + for (int i = 0; i < points.length; ++i) { + int x1 = points[i][0], y1 = points[i][1]; + for (int j = 0; j < i; ++j) { + int x2 = points[j][0], y2 = points[j][1]; + int x3 = Math.min(x1, x2), y3 = Math.min(y1, y2); + int x4 = Math.max(x1, x2), y4 = Math.max(y1, y2); + if (check(points, x3, y3, x4, y4)) { + ans = Math.max(ans, (x4 - x3) * (y4 - y3)); + } + } + } + return ans; + } + + private boolean check(int[][] points, int x1, int y1, int x2, int y2) { + int cnt = 0; + for (var p : points) { + int x = p[0]; + int y = p[1]; + if (x < x1 || x > x2 || y < y1 || y > y2) { + continue; + } + if ((x == x1 || x == x2) && (y == y1 || y == y2)) { + cnt++; + continue; + } + return false; + } + return cnt == 4; + } +} ``` #### C++ ```cpp - +class Solution { +public: + int maxRectangleArea(vector>& points) { + auto check = [&](int x1, int y1, int x2, int y2) -> bool { + int cnt = 0; + for (const auto& point : points) { + int x = point[0]; + int y = point[1]; + if (x < x1 || x > x2 || y < y1 || y > y2) { + continue; + } + if ((x == x1 || x == x2) && (y == y1 || y == y2)) { + cnt++; + continue; + } + return false; + } + return cnt == 4; + }; + + int ans = -1; + for (int i = 0; i < points.size(); i++) { + int x1 = points[i][0], y1 = points[i][1]; + for (int j = 0; j < i; j++) { + int x2 = points[j][0], y2 = points[j][1]; + int x3 = min(x1, x2), y3 = min(y1, y2); + int x4 = max(x1, x2), y4 = max(y1, y2); + if (check(x3, y3, x4, y4)) { + ans = max(ans, (x4 - x3) * (y4 - y3)); + } + } + } + return ans; + } +}; ``` #### Go ```go +func maxRectangleArea(points [][]int) int { + check := func(x1, y1, x2, y2 int) bool { + cnt := 0 + for _, point := range points { + x, y := point[0], point[1] + if x < x1 || x > x2 || y < y1 || y > y2 { + continue + } + if (x == x1 || x == x2) && (y == y1 || y == y2) { + cnt++ + continue + } + return false + } + return cnt == 4 + } + + ans := -1 + for i := 0; i < len(points); i++ { + x1, y1 := points[i][0], points[i][1] + for j := 0; j < i; j++ { + x2, y2 := points[j][0], points[j][1] + x3, y3 := min(x1, x2), min(y1, y2) + x4, y4 := max(x1, x2), max(y1, y2) + if check(x3, y3, x4, y4) { + ans = max(ans, (x4-x3)*(y4-y3)) + } + } + } + return ans +} +``` +#### TypeScript + +```ts +function maxRectangleArea(points: number[][]): number { + const check = (x1: number, y1: number, x2: number, y2: number): boolean => { + let cnt = 0; + for (const point of points) { + const [x, y] = point; + if (x < x1 || x > x2 || y < y1 || y > y2) { + continue; + } + if ((x === x1 || x === x2) && (y === y1 || y === y2)) { + cnt++; + continue; + } + return false; + } + return cnt === 4; + }; + + let ans = -1; + for (let i = 0; i < points.length; i++) { + const [x1, y1] = points[i]; + for (let j = 0; j < i; j++) { + const [x2, y2] = points[j]; + const [x3, y3] = [Math.min(x1, x2), Math.min(y1, y2)]; + const [x4, y4] = [Math.max(x1, x2), Math.max(y1, y2)]; + if (check(x3, y3, x4, y4)) { + ans = Math.max(ans, (x4 - x3) * (y4 - y3)); + } + } + } + return ans; +} ``` diff --git a/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/README_EN.md b/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/README_EN.md index bf91f7af93711..2201cadb623dc 100644 --- a/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/README_EN.md +++ b/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/README_EN.md @@ -2,6 +2,14 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3380.Maximum%20Area%20Rectangle%20With%20Point%20Constraints%20I/README_EN.md +tags: + - Binary Indexed Tree + - Segment Tree + - Geometry + - Array + - Math + - Enumeration + - Sorting --- @@ -85,32 +93,189 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3380.Ma -### Solution 1 +### Solution 1: Enumeration + +We can enumerate the bottom-left corner $(x_3, y_3)$ and the top-right corner $(x_4, y_4)$ of the rectangle. Then, we enumerate all points $(x, y)$ and check if the point is inside or on the boundary of the rectangle. If it is, it does not meet the condition. Otherwise, we exclude the points outside the rectangle and check if there are 4 remaining points. If there are, these 4 points can form a rectangle. We calculate the area of the rectangle and take the maximum value. + +The time complexity is $O(n^3)$, where $n$ is the length of the array $\textit{points}$. The space complexity is $O(1)$. #### Python3 ```python - +class Solution: + def maxRectangleArea(self, points: List[List[int]]) -> int: + def check(x1: int, y1: int, x2: int, y2: int) -> bool: + cnt = 0 + for x, y in points: + if x < x1 or x > x2 or y < y1 or y > y2: + continue + if (x == x1 or x == x2) and (y == y1 or y == y2): + cnt += 1 + continue + return False + return cnt == 4 + + ans = -1 + for i, (x1, y1) in enumerate(points): + for x2, y2 in points[:i]: + x3, y3 = min(x1, x2), min(y1, y2) + x4, y4 = max(x1, x2), max(y1, y2) + if check(x3, y3, x4, y4): + ans = max(ans, (x4 - x3) * (y4 - y3)) + return ans ``` #### Java ```java - +class Solution { + public int maxRectangleArea(int[][] points) { + int ans = -1; + for (int i = 0; i < points.length; ++i) { + int x1 = points[i][0], y1 = points[i][1]; + for (int j = 0; j < i; ++j) { + int x2 = points[j][0], y2 = points[j][1]; + int x3 = Math.min(x1, x2), y3 = Math.min(y1, y2); + int x4 = Math.max(x1, x2), y4 = Math.max(y1, y2); + if (check(points, x3, y3, x4, y4)) { + ans = Math.max(ans, (x4 - x3) * (y4 - y3)); + } + } + } + return ans; + } + + private boolean check(int[][] points, int x1, int y1, int x2, int y2) { + int cnt = 0; + for (var p : points) { + int x = p[0]; + int y = p[1]; + if (x < x1 || x > x2 || y < y1 || y > y2) { + continue; + } + if ((x == x1 || x == x2) && (y == y1 || y == y2)) { + cnt++; + continue; + } + return false; + } + return cnt == 4; + } +} ``` #### C++ ```cpp - +class Solution { +public: + int maxRectangleArea(vector>& points) { + auto check = [&](int x1, int y1, int x2, int y2) -> bool { + int cnt = 0; + for (const auto& point : points) { + int x = point[0]; + int y = point[1]; + if (x < x1 || x > x2 || y < y1 || y > y2) { + continue; + } + if ((x == x1 || x == x2) && (y == y1 || y == y2)) { + cnt++; + continue; + } + return false; + } + return cnt == 4; + }; + + int ans = -1; + for (int i = 0; i < points.size(); i++) { + int x1 = points[i][0], y1 = points[i][1]; + for (int j = 0; j < i; j++) { + int x2 = points[j][0], y2 = points[j][1]; + int x3 = min(x1, x2), y3 = min(y1, y2); + int x4 = max(x1, x2), y4 = max(y1, y2); + if (check(x3, y3, x4, y4)) { + ans = max(ans, (x4 - x3) * (y4 - y3)); + } + } + } + return ans; + } +}; ``` #### Go ```go +func maxRectangleArea(points [][]int) int { + check := func(x1, y1, x2, y2 int) bool { + cnt := 0 + for _, point := range points { + x, y := point[0], point[1] + if x < x1 || x > x2 || y < y1 || y > y2 { + continue + } + if (x == x1 || x == x2) && (y == y1 || y == y2) { + cnt++ + continue + } + return false + } + return cnt == 4 + } + + ans := -1 + for i := 0; i < len(points); i++ { + x1, y1 := points[i][0], points[i][1] + for j := 0; j < i; j++ { + x2, y2 := points[j][0], points[j][1] + x3, y3 := min(x1, x2), min(y1, y2) + x4, y4 := max(x1, x2), max(y1, y2) + if check(x3, y3, x4, y4) { + ans = max(ans, (x4-x3)*(y4-y3)) + } + } + } + return ans +} +``` +#### TypeScript + +```ts +function maxRectangleArea(points: number[][]): number { + const check = (x1: number, y1: number, x2: number, y2: number): boolean => { + let cnt = 0; + for (const point of points) { + const [x, y] = point; + if (x < x1 || x > x2 || y < y1 || y > y2) { + continue; + } + if ((x === x1 || x === x2) && (y === y1 || y === y2)) { + cnt++; + continue; + } + return false; + } + return cnt === 4; + }; + + let ans = -1; + for (let i = 0; i < points.length; i++) { + const [x1, y1] = points[i]; + for (let j = 0; j < i; j++) { + const [x2, y2] = points[j]; + const [x3, y3] = [Math.min(x1, x2), Math.min(y1, y2)]; + const [x4, y4] = [Math.max(x1, x2), Math.max(y1, y2)]; + if (check(x3, y3, x4, y4)) { + ans = Math.max(ans, (x4 - x3) * (y4 - y3)); + } + } + } + return ans; +} ``` diff --git a/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/Solution.cpp b/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/Solution.cpp new file mode 100644 index 0000000000000..aed4d579cc4a0 --- /dev/null +++ b/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/Solution.cpp @@ -0,0 +1,35 @@ +class Solution { +public: + int maxRectangleArea(vector>& points) { + auto check = [&](int x1, int y1, int x2, int y2) -> bool { + int cnt = 0; + for (const auto& point : points) { + int x = point[0]; + int y = point[1]; + if (x < x1 || x > x2 || y < y1 || y > y2) { + continue; + } + if ((x == x1 || x == x2) && (y == y1 || y == y2)) { + cnt++; + continue; + } + return false; + } + return cnt == 4; + }; + + int ans = -1; + for (int i = 0; i < points.size(); i++) { + int x1 = points[i][0], y1 = points[i][1]; + for (int j = 0; j < i; j++) { + int x2 = points[j][0], y2 = points[j][1]; + int x3 = min(x1, x2), y3 = min(y1, y2); + int x4 = max(x1, x2), y4 = max(y1, y2); + if (check(x3, y3, x4, y4)) { + ans = max(ans, (x4 - x3) * (y4 - y3)); + } + } + } + return ans; + } +}; diff --git a/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/Solution.go b/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/Solution.go new file mode 100644 index 0000000000000..03ccde2a8bd2b --- /dev/null +++ b/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/Solution.go @@ -0,0 +1,31 @@ +func maxRectangleArea(points [][]int) int { + check := func(x1, y1, x2, y2 int) bool { + cnt := 0 + for _, point := range points { + x, y := point[0], point[1] + if x < x1 || x > x2 || y < y1 || y > y2 { + continue + } + if (x == x1 || x == x2) && (y == y1 || y == y2) { + cnt++ + continue + } + return false + } + return cnt == 4 + } + + ans := -1 + for i := 0; i < len(points); i++ { + x1, y1 := points[i][0], points[i][1] + for j := 0; j < i; j++ { + x2, y2 := points[j][0], points[j][1] + x3, y3 := min(x1, x2), min(y1, y2) + x4, y4 := max(x1, x2), max(y1, y2) + if check(x3, y3, x4, y4) { + ans = max(ans, (x4-x3)*(y4-y3)) + } + } + } + return ans +} diff --git a/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/Solution.java b/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/Solution.java new file mode 100644 index 0000000000000..471f5c110eb6b --- /dev/null +++ b/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/Solution.java @@ -0,0 +1,34 @@ +class Solution { + public int maxRectangleArea(int[][] points) { + int ans = -1; + for (int i = 0; i < points.length; ++i) { + int x1 = points[i][0], y1 = points[i][1]; + for (int j = 0; j < i; ++j) { + int x2 = points[j][0], y2 = points[j][1]; + int x3 = Math.min(x1, x2), y3 = Math.min(y1, y2); + int x4 = Math.max(x1, x2), y4 = Math.max(y1, y2); + if (check(points, x3, y3, x4, y4)) { + ans = Math.max(ans, (x4 - x3) * (y4 - y3)); + } + } + } + return ans; + } + + private boolean check(int[][] points, int x1, int y1, int x2, int y2) { + int cnt = 0; + for (var p : points) { + int x = p[0]; + int y = p[1]; + if (x < x1 || x > x2 || y < y1 || y > y2) { + continue; + } + if ((x == x1 || x == x2) && (y == y1 || y == y2)) { + cnt++; + continue; + } + return false; + } + return cnt == 4; + } +} diff --git a/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/Solution.py b/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/Solution.py new file mode 100644 index 0000000000000..2f15a12ae7877 --- /dev/null +++ b/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/Solution.py @@ -0,0 +1,21 @@ +class Solution: + def maxRectangleArea(self, points: List[List[int]]) -> int: + def check(x1: int, y1: int, x2: int, y2: int) -> bool: + cnt = 0 + for x, y in points: + if x < x1 or x > x2 or y < y1 or y > y2: + continue + if (x == x1 or x == x2) and (y == y1 or y == y2): + cnt += 1 + continue + return False + return cnt == 4 + + ans = -1 + for i, (x1, y1) in enumerate(points): + for x2, y2 in points[:i]: + x3, y3 = min(x1, x2), min(y1, y2) + x4, y4 = max(x1, x2), max(y1, y2) + if check(x3, y3, x4, y4): + ans = max(ans, (x4 - x3) * (y4 - y3)) + return ans diff --git a/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/Solution.ts b/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/Solution.ts new file mode 100644 index 0000000000000..170e2a4d1df1b --- /dev/null +++ b/solution/3300-3399/3380.Maximum Area Rectangle With Point Constraints I/Solution.ts @@ -0,0 +1,31 @@ +function maxRectangleArea(points: number[][]): number { + const check = (x1: number, y1: number, x2: number, y2: number): boolean => { + let cnt = 0; + for (const point of points) { + const [x, y] = point; + if (x < x1 || x > x2 || y < y1 || y > y2) { + continue; + } + if ((x === x1 || x === x2) && (y === y1 || y === y2)) { + cnt++; + continue; + } + return false; + } + return cnt === 4; + }; + + let ans = -1; + for (let i = 0; i < points.length; i++) { + const [x1, y1] = points[i]; + for (let j = 0; j < i; j++) { + const [x2, y2] = points[j]; + const [x3, y3] = [Math.min(x1, x2), Math.min(y1, y2)]; + const [x4, y4] = [Math.max(x1, x2), Math.max(y1, y2)]; + if (check(x3, y3, x4, y4)) { + ans = Math.max(ans, (x4 - x3) * (y4 - y3)); + } + } + } + return ans; +} diff --git a/solution/3300-3399/3381.Maximum Subarray Sum With Length Divisible by K/README.md b/solution/3300-3399/3381.Maximum Subarray Sum With Length Divisible by K/README.md index 90fd97fff34ba..fcdbe78a63445 100644 --- a/solution/3300-3399/3381.Maximum Subarray Sum With Length Divisible by K/README.md +++ b/solution/3300-3399/3381.Maximum Subarray Sum With Length Divisible by K/README.md @@ -2,6 +2,10 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3381.Maximum%20Subarray%20Sum%20With%20Length%20Divisible%20by%20K/README.md +tags: + - 数组 + - 哈希表 + - 前缀和 --- diff --git a/solution/3300-3399/3381.Maximum Subarray Sum With Length Divisible by K/README_EN.md b/solution/3300-3399/3381.Maximum Subarray Sum With Length Divisible by K/README_EN.md index 5420ba8a7430e..34851c1969635 100644 --- a/solution/3300-3399/3381.Maximum Subarray Sum With Length Divisible by K/README_EN.md +++ b/solution/3300-3399/3381.Maximum Subarray Sum With Length Divisible by K/README_EN.md @@ -2,6 +2,10 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3381.Maximum%20Subarray%20Sum%20With%20Length%20Divisible%20by%20K/README_EN.md +tags: + - Array + - Hash Table + - Prefix Sum --- diff --git a/solution/3300-3399/3382.Maximum Area Rectangle With Point Constraints II/README.md b/solution/3300-3399/3382.Maximum Area Rectangle With Point Constraints II/README.md index f5bc444073d73..9c21ff18e6809 100644 --- a/solution/3300-3399/3382.Maximum Area Rectangle With Point Constraints II/README.md +++ b/solution/3300-3399/3382.Maximum Area Rectangle With Point Constraints II/README.md @@ -2,6 +2,13 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3382.Maximum%20Area%20Rectangle%20With%20Point%20Constraints%20II/README.md +tags: + - 树状数组 + - 线段树 + - 几何 + - 数组 + - 数学 + - 排序 --- diff --git a/solution/3300-3399/3382.Maximum Area Rectangle With Point Constraints II/README_EN.md b/solution/3300-3399/3382.Maximum Area Rectangle With Point Constraints II/README_EN.md index c7489033b2eb6..44520825e61b5 100644 --- a/solution/3300-3399/3382.Maximum Area Rectangle With Point Constraints II/README_EN.md +++ b/solution/3300-3399/3382.Maximum Area Rectangle With Point Constraints II/README_EN.md @@ -2,6 +2,13 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3382.Maximum%20Area%20Rectangle%20With%20Point%20Constraints%20II/README_EN.md +tags: + - Binary Indexed Tree + - Segment Tree + - Geometry + - Array + - Math + - Sorting --- diff --git a/solution/3300-3399/3383.Minimum Runes to Add to Cast Spell/README.md b/solution/3300-3399/3383.Minimum Runes to Add to Cast Spell/README.md index 027be94b45fea..04ac6bd6b0c68 100644 --- a/solution/3300-3399/3383.Minimum Runes to Add to Cast Spell/README.md +++ b/solution/3300-3399/3383.Minimum Runes to Add to Cast Spell/README.md @@ -2,11 +2,17 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3383.Minimum%20Runes%20to%20Add%20to%20Cast%20Spell/README.md +tags: + - 深度优先搜索 + - 广度优先搜索 + - 图 + - 拓扑排序 + - 数组 --- -# [3383. Minimum Runes to Add to Cast Spell 🔒](https://leetcode.cn/problems/minimum-runes-to-add-to-cast-spell) +# [3383. 施法所需最低符文数量 🔒](https://leetcode.cn/problems/minimum-runes-to-add-to-cast-spell) [English Version](/solution/3300-3399/3383.Minimum%20Runes%20to%20Add%20to%20Cast%20Spell/README_EN.md) @@ -14,55 +20,57 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3383.Mi -

Alice has just graduated from wizard school, and wishes to cast a magic spell to celebrate. The magic spell contains certain focus points where magic needs to be concentrated, and some of these focus points contain magic crystals which serve as the spell's energy source. Focus points can be linked through directed runes, which channel magic flow from one focus point to another.

+

Alice 刚刚从巫师学校毕业,并且希望施展一个魔法咒语来庆祝。魔法咒语包含某些需要集中魔力的焦点,其中一些焦点含有作为咒语能量源的魔法水晶。焦点可以通过 有向符文 进行连接,这些符文将魔力流从一个焦点传输到另一个焦点。

-

You are given a integer n denoting the number of focus points and an array of integers crystals where crystals[i] indicates a focus point which holds a magic crystal. You are also given two integer arrays flowFrom and flowTo, which represent the existing directed runes. The ith rune allows magic to freely flow from focus point flowFrom[i] to focus point flowTo[i].

+

给定一个整数 n 表示焦点的数量,以及一个整数数组 crystals,其中 crystals[i] 表示有魔法水晶的焦点。同时给定两个整数数组 flowFrom 和 flowTo,表示存在的 有向符文。第 ith 个符文允许魔力流从焦点 flowFrom[i] 传输到焦点 flowTo[i]

-

You need to find the number of directed runes Alice must add to her spell, such that each focus point either:

+

你需要找到 Alice 必须添加到她的咒语中的定向符文数量,使得每个焦点要么:

    -
  • Contains a magic crystal.
  • -
  • Receives magic flow from another focus point.
  • +
  • 包含 一个魔法水晶。
  • +
  • 从其它焦点 接收 魔力流。
-

Return the minimum number of directed runes that she should add.

+

返回她所需要添加的 最少 有向符文数量。

 

-

Example 1:

+ +

示例 1:

-

Input: n = 6, crystals = [0], flowFrom = [0,1,2,3], flowTo = [1,2,3,0]

+

输入:n = 6, crystals = [0], flowFrom = [0,1,2,3], flowTo = [1,2,3,0]

-

Output: 2

+

输出:2

-

Explanation: 

+

解释:

-

Add two directed runes:

+

添加两个有向符文:

    -
  • From focus point 0 to focus point 4.
  • -
  • From focus point 0 to focus point 5.
  • +
  • 从焦点 0 到焦点 4。
  • +
  • 从焦点 0 到焦点 5。
-

Example 2:

+

示例 2:

-

Input: n = 7, crystals = [3,5], flowFrom = [0,1,2,3,5], flowTo = [1,2,0,4,6]

+

输入:n = 7, crystals = [3,5], flowFrom = [0,1,2,3,5], flowTo = [1,2,0,4,6]

-

Output: 1

+

输出:1

-

Explanation: 

+

解释:

-

Add a directed rune from focus point 4 to focus point 2.

+

添加从焦点 4 到焦点 2 的有向符文。

 

-

Constraints:

+ +

提示:

  • 2 <= n <= 105
  • @@ -71,7 +79,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3383.Mi
  • 1 <= flowFrom.length == flowTo.length <= min(2 * 105, (n * (n - 1)) / 2)
  • 0 <= flowFrom[i], flowTo[i] <= n - 1
  • flowFrom[i] != flowTo[i]
  • -
  • All pre-existing directed runes are distinct.
  • +
  • 所有的有向符文 互不相同
diff --git a/solution/3300-3399/3383.Minimum Runes to Add to Cast Spell/README_EN.md b/solution/3300-3399/3383.Minimum Runes to Add to Cast Spell/README_EN.md index a8237af83637b..6c6d2c5c098e3 100644 --- a/solution/3300-3399/3383.Minimum Runes to Add to Cast Spell/README_EN.md +++ b/solution/3300-3399/3383.Minimum Runes to Add to Cast Spell/README_EN.md @@ -2,6 +2,12 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3383.Minimum%20Runes%20to%20Add%20to%20Cast%20Spell/README_EN.md +tags: + - Depth-First Search + - Breadth-First Search + - Graph + - Topological Sort + - Array --- diff --git a/solution/3300-3399/3384.Team Dominance by Pass Success/README.md b/solution/3300-3399/3384.Team Dominance by Pass Success/README.md index 4c2ec8f0f1d73..65fd4b74ea843 100644 --- a/solution/3300-3399/3384.Team Dominance by Pass Success/README.md +++ b/solution/3300-3399/3384.Team Dominance by Pass Success/README.md @@ -8,7 +8,7 @@ tags: -# [3384. Team Dominance by Pass Success 🔒](https://leetcode.cn/problems/team-dominance-by-pass-success) +# [3384. 球队传球成功的优势得分 🔒](https://leetcode.cn/problems/team-dominance-by-pass-success) [English Version](/solution/3300-3399/3384.Team%20Dominance%20by%20Pass%20Success/README_EN.md) @@ -16,7 +16,7 @@ tags: -

Table: Teams

+

表:Teams

 +-------------+---------+
@@ -25,12 +25,12 @@ tags:
 | player_id   | int     |
 | team_name   | varchar | 
 +-------------+---------+
-player_id is the unique key for this table.
-Each row contains the unique identifier for player and the name of one of the teams participating in that match.
+player_id 是这张表的唯一主键。
+每一行包含队员的唯一标识以及在该场比赛中参赛的某支队伍的名称。
 
 
-

Table: Passes

+

表:Passes

 +-------------+---------+
@@ -40,37 +40,38 @@ Each row contains the unique identifier for player and the name of one of the te
 | time_stamp  | varchar |
 | pass_to     | int     |
 +-------------+---------+
-(pass_from, time_stamp) is the primary key for this table.
-pass_from is a foreign key to player_id from Teams table.
-Each row represents a pass made during a match, time_stamp represents the time in minutes (00:00-90:00) when the pass was made,
-pass_to is the player_id of the player receiving the pass.
+(pass_from, time_stamp) 是这张表的主键。
+pass_from 是指向 Teams 表 player_id 字段的外键。
+每一行代表比赛期间的一次传球,time_stamp 表示传球发生的分钟时间(00:00-90:00),
+pass_to 表示 player_id 对应队员接球。
 
 
-

Write a solution to calculate the dominance score for each team in both halves of the match. The rules are as follows:

+

编写一个解决方案来计算每支球队 在上半场的优势得分。规则如下:

    -
  • A match is divided into two halves: first half (00:00-45:00 minutes) and second half (45:01-90:00 minutes)
  • -
  • The dominance score is calculated based on successful and intercepted passes: +
  • 一场比赛分为两个半场:上半场00:00-45:00 分钟)和 下半场45:01-90:00 分钟)
  • +
  • 优势得分是根据成功和截获的传球来计算的:
      -
    • When pass_to is a player from the same team: +1 point
    • -
    • When pass_to is a player from the opposing team (interception): -1 point
    • +
    • 当 pass_to 是 同球队 的队员:+1
    • +
    • 当 pass_to 是 对方球队 的队员(截获):-1
  • -
  • A higher dominance score indicates better passing performance
  • +
  • 更高的优势得分表明传球表现更好
-

Return the result table ordered by team_name and half_number in ascending order.

+

返回结果表以 team_name 和 half_number 升序 排序。

-

The result format is in the following example.

+

结果格式如下所示。

 

-

Example:

+ +

示例:

-

Input:

+

输入:

-

Teams table:

+

Teams 表:

 +------------+-----------+
@@ -85,7 +86,7 @@ pass_to is the player_id of the player receiving the pass.
 +------------+-----------+
 
-

Passes table:

+

Passes 表:

 +-----------+------------+---------+
@@ -102,7 +103,7 @@ pass_to is the player_id of the player receiving the pass.
 +-----------+------------+---------+
 
-

Output:

+

输出:

 +-----------+-------------+-----------+
@@ -115,43 +116,43 @@ pass_to is the player_id of the player receiving the pass.
 +-----------+-------------+-----------+
 
-

Explanation:

+

解释:

    -
  • First Half (00:00-45:00): +
  • 前半场(00:00-45:00):
      -
    • Arsenal's passes: +
    • 阿森纳的传球:
        -
      • 1 → 2 (00:15): Successful pass (+1)
      • -
      • 2 → 3 (00:45): Successful pass (+1)
      • -
      • 3 → 1 (01:15): Successful pass (+1)
      • +
      • 1 → 2 (00:15):成功传球(+1)
      • +
      • 2 → 3 (00:45):成功传球(+1)
      • +
      • 3 → 1 (01:15):成功传球(+1)
    • -
    • Chelsea's passes: +
    • 切尔西的传球:
        -
      • 4 → 1 (00:30): Intercepted by Arsenal (-1)
      • +
      • 4 → 1 (00:30): 被阿森纳截获(-1)
  • -
  • Second Half (45:01-90:00): +
  • 下半场(45:01-90:00):
      -
    • Arsenal's passes: +
    • 阿森纳的传球:
        -
      • 2 → 3 (46:00): Successful pass (+1)
      • -
      • 3 → 4 (46:15): Intercepted by Chelsea (-1)
      • -
      • 1 → 2 (46:45): Successful pass (+1)
      • +
      • 2 → 3 (46:00):成功传球(+1)
      • +
      • 3 → 4 (46:15):被切尔西截获 (-1)
      • +
      • 1 → 2 (46:45):成功传球(+1)
    • -
    • Chelsea's passes: +
    • 切尔西的传球:
        -
      • 5 → 6 (46:30): Successful pass (+1)
      • +
      • 5 → 6 (46:30):成功传球(+1)
  • -
  • The results are ordered by team_name and then half_number
  • +
  • 结果以 team_name 和 half_number 升序排序
@@ -162,7 +163,9 @@ pass_to is the player_id of the player receiving the pass. -### 方法一 +### 方法一:等值连接 + 分组求和 + +我们可以通过等值连接,找到每次传球的发起方和接收方所在的球队,然后根据传球的时间戳判断传球发生在上半场还是下半场,根据传球的发起方和接收方所在的球队是否相同,计算出每次传球的优势值,最后按照球队名称和半场编号进行分组求和,得到每支球队在上半场和下半场的优势值。 diff --git a/solution/3300-3399/3384.Team Dominance by Pass Success/README_EN.md b/solution/3300-3399/3384.Team Dominance by Pass Success/README_EN.md index 2b429c2148392..a0c685340bf36 100644 --- a/solution/3300-3399/3384.Team Dominance by Pass Success/README_EN.md +++ b/solution/3300-3399/3384.Team Dominance by Pass Success/README_EN.md @@ -23,7 +23,7 @@ tags: | Column Name | Type | +-------------+---------+ | player_id | int | -| team_name | varchar | +| team_name | varchar | +-------------+---------+ player_id is the unique key for this table. Each row contains the unique identifier for player and the name of one of the teams participating in that match. @@ -162,7 +162,9 @@ pass_to is the player_id of the player receiving the pass. -### Solution 1 +### Solution 1: Equi-Join + Group By and Sum + +We can use an equi-join to find the teams of both the passer and the receiver for each pass. Then, based on the timestamp, we determine whether the pass occurred in the first half or the second half. By checking if the passer and receiver belong to the same team, we calculate the advantage value for each pass. Finally, we group by team name and half number, and sum the advantage values to get the advantage value for each team in the first and second halves. diff --git a/solution/DATABASE_README.md b/solution/DATABASE_README.md index a5346c460babc..7faa9369b165a 100644 --- a/solution/DATABASE_README.md +++ b/solution/DATABASE_README.md @@ -303,7 +303,7 @@ | 3358 | [评分为 NULL 的图书](/solution/3300-3399/3358.Books%20with%20NULL%20Ratings/README.md) | `数据库` | 简单 | 🔒 | | 3368 | [首字母大写](/solution/3300-3399/3368.First%20Letter%20Capitalization/README.md) | `数据库` | 困难 | 🔒 | | 3374 | [首字母大写 II](/solution/3300-3399/3374.First%20Letter%20Capitalization%20II/README.md) | `数据库` | 困难 | | -| 3384 | [Team Dominance by Pass Success](/solution/3300-3399/3384.Team%20Dominance%20by%20Pass%20Success/README.md) | | 困难 | 🔒 | +| 3384 | [球队传球成功的优势得分](/solution/3300-3399/3384.Team%20Dominance%20by%20Pass%20Success/README.md) | `数据库` | 困难 | 🔒 | ## 版权 diff --git a/solution/DATABASE_README_EN.md b/solution/DATABASE_README_EN.md index 4cfedf08c0eb8..12c86a8ce697f 100644 --- a/solution/DATABASE_README_EN.md +++ b/solution/DATABASE_README_EN.md @@ -301,7 +301,7 @@ Press Control + F(or Command + F on | 3358 | [Books with NULL Ratings](/solution/3300-3399/3358.Books%20with%20NULL%20Ratings/README_EN.md) | `Database` | Easy | 🔒 | | 3368 | [First Letter Capitalization](/solution/3300-3399/3368.First%20Letter%20Capitalization/README_EN.md) | `Database` | Hard | 🔒 | | 3374 | [First Letter Capitalization II](/solution/3300-3399/3374.First%20Letter%20Capitalization%20II/README_EN.md) | `Database` | Hard | | -| 3384 | [Team Dominance by Pass Success](/solution/3300-3399/3384.Team%20Dominance%20by%20Pass%20Success/README_EN.md) | | Hard | 🔒 | +| 3384 | [Team Dominance by Pass Success](/solution/3300-3399/3384.Team%20Dominance%20by%20Pass%20Success/README_EN.md) | `Database` | Hard | 🔒 | ## Copyright diff --git a/solution/README.md b/solution/README.md index d94177e3d0152..226ea5aea0194 100644 --- a/solution/README.md +++ b/solution/README.md @@ -369,6 +369,7 @@ | 0356 | [直线镜像](/solution/0300-0399/0356.Line%20Reflection/README.md) | `数组`,`哈希表`,`数学` | 中等 | 🔒 | | 0357 | [统计各位数字都不同的数字个数](/solution/0300-0399/0357.Count%20Numbers%20with%20Unique%20Digits/README.md) | `数学`,`动态规划`,`回溯` | 中等 | | | 0358 | [K 距离间隔重排字符串](/solution/0300-0399/0358.Rearrange%20String%20k%20Distance%20Apart/README.md) | `贪心`,`哈希表`,`字符串`,`计数`,`排序`,`堆(优先队列)` | 困难 | 🔒 | +| 0359 | [日志速率限制器](/solution/0300-0399/0359.Logger%20Rate%20Limiter/README.md) | `设计`,`哈希表`,`数据流` | 简单 | 🔒 | | 0360 | [有序转化数组](/solution/0300-0399/0360.Sort%20Transformed%20Array/README.md) | `数组`,`数学`,`双指针`,`排序` | 中等 | 🔒 | | 0361 | [轰炸敌人](/solution/0300-0399/0361.Bomb%20Enemy/README.md) | `数组`,`动态规划`,`矩阵` | 中等 | 🔒 | | 0362 | [敲击计数器](/solution/0300-0399/0362.Design%20Hit%20Counter/README.md) | `设计`,`队列`,`数组`,`二分查找`,`数据流` | 中等 | 🔒 | @@ -3384,16 +3385,16 @@ | 3372 | [连接两棵树后最大目标节点数目 I](/solution/3300-3399/3372.Maximize%20the%20Number%20of%20Target%20Nodes%20After%20Connecting%20Trees%20I/README.md) | `树`,`深度优先搜索`,`广度优先搜索` | 中等 | 第 426 场周赛 | | 3373 | [连接两棵树后最大目标节点数目 II](/solution/3300-3399/3373.Maximize%20the%20Number%20of%20Target%20Nodes%20After%20Connecting%20Trees%20II/README.md) | `树`,`深度优先搜索`,`广度优先搜索` | 困难 | 第 426 场周赛 | | 3374 | [首字母大写 II](/solution/3300-3399/3374.First%20Letter%20Capitalization%20II/README.md) | `数据库` | 困难 | | -| 3375 | [使数组的值全部为 K 的最少操作次数](/solution/3300-3399/3375.Minimum%20Operations%20to%20Make%20Array%20Values%20Equal%20to%20K/README.md) | | 简单 | 第 145 场双周赛 | -| 3376 | [破解锁的最少时间 I](/solution/3300-3399/3376.Minimum%20Time%20to%20Break%20Locks%20I/README.md) | | 中等 | 第 145 场双周赛 | -| 3377 | [使两个整数相等的数位操作](/solution/3300-3399/3377.Digit%20Operations%20to%20Make%20Two%20Integers%20Equal/README.md) | | 中等 | 第 145 场双周赛 | -| 3378 | [统计最小公倍数图中的连通块数目](/solution/3300-3399/3378.Count%20Connected%20Components%20in%20LCM%20Graph/README.md) | | 困难 | 第 145 场双周赛 | -| 3379 | [转换数组](/solution/3300-3399/3379.Transformed%20Array/README.md) | | 简单 | 第 427 场周赛 | -| 3380 | [用点构造面积最大的矩形 I](/solution/3300-3399/3380.Maximum%20Area%20Rectangle%20With%20Point%20Constraints%20I/README.md) | | 中等 | 第 427 场周赛 | -| 3381 | [长度可被 K 整除的子数组的最大元素和](/solution/3300-3399/3381.Maximum%20Subarray%20Sum%20With%20Length%20Divisible%20by%20K/README.md) | | 中等 | 第 427 场周赛 | -| 3382 | [用点构造面积最大的矩形 II](/solution/3300-3399/3382.Maximum%20Area%20Rectangle%20With%20Point%20Constraints%20II/README.md) | | 困难 | 第 427 场周赛 | -| 3383 | [Minimum Runes to Add to Cast Spell](/solution/3300-3399/3383.Minimum%20Runes%20to%20Add%20to%20Cast%20Spell/README.md) | | 困难 | 🔒 | -| 3384 | [Team Dominance by Pass Success](/solution/3300-3399/3384.Team%20Dominance%20by%20Pass%20Success/README.md) | | 困难 | 🔒 | +| 3375 | [使数组的值全部为 K 的最少操作次数](/solution/3300-3399/3375.Minimum%20Operations%20to%20Make%20Array%20Values%20Equal%20to%20K/README.md) | `数组`,`哈希表` | 简单 | 第 145 场双周赛 | +| 3376 | [破解锁的最少时间 I](/solution/3300-3399/3376.Minimum%20Time%20to%20Break%20Locks%20I/README.md) | `位运算`,`数组`,`动态规划`,`回溯`,`状态压缩` | 中等 | 第 145 场双周赛 | +| 3377 | [使两个整数相等的数位操作](/solution/3300-3399/3377.Digit%20Operations%20to%20Make%20Two%20Integers%20Equal/README.md) | `图`,`数学`,`数论`,`最短路`,`堆(优先队列)` | 中等 | 第 145 场双周赛 | +| 3378 | [统计最小公倍数图中的连通块数目](/solution/3300-3399/3378.Count%20Connected%20Components%20in%20LCM%20Graph/README.md) | `并查集`,`数组`,`哈希表`,`数学`,`数论` | 困难 | 第 145 场双周赛 | +| 3379 | [转换数组](/solution/3300-3399/3379.Transformed%20Array/README.md) | `数组`,`模拟` | 简单 | 第 427 场周赛 | +| 3380 | [用点构造面积最大的矩形 I](/solution/3300-3399/3380.Maximum%20Area%20Rectangle%20With%20Point%20Constraints%20I/README.md) | `树状数组`,`线段树`,`几何`,`数组`,`数学`,`枚举`,`排序` | 中等 | 第 427 场周赛 | +| 3381 | [长度可被 K 整除的子数组的最大元素和](/solution/3300-3399/3381.Maximum%20Subarray%20Sum%20With%20Length%20Divisible%20by%20K/README.md) | `数组`,`哈希表`,`前缀和` | 中等 | 第 427 场周赛 | +| 3382 | [用点构造面积最大的矩形 II](/solution/3300-3399/3382.Maximum%20Area%20Rectangle%20With%20Point%20Constraints%20II/README.md) | `树状数组`,`线段树`,`几何`,`数组`,`数学`,`排序` | 困难 | 第 427 场周赛 | +| 3383 | [施法所需最低符文数量](/solution/3300-3399/3383.Minimum%20Runes%20to%20Add%20to%20Cast%20Spell/README.md) | `深度优先搜索`,`广度优先搜索`,`图`,`拓扑排序`,`数组` | 困难 | 🔒 | +| 3384 | [球队传球成功的优势得分](/solution/3300-3399/3384.Team%20Dominance%20by%20Pass%20Success/README.md) | `数据库` | 困难 | 🔒 | ## 版权 diff --git a/solution/README_EN.md b/solution/README_EN.md index e53481d4f22f2..7a0366117385a 100644 --- a/solution/README_EN.md +++ b/solution/README_EN.md @@ -367,6 +367,7 @@ Press Control + F(or Command + F on | 0356 | [Line Reflection](/solution/0300-0399/0356.Line%20Reflection/README_EN.md) | `Array`,`Hash Table`,`Math` | Medium | 🔒 | | 0357 | [Count Numbers with Unique Digits](/solution/0300-0399/0357.Count%20Numbers%20with%20Unique%20Digits/README_EN.md) | `Math`,`Dynamic Programming`,`Backtracking` | Medium | | | 0358 | [Rearrange String k Distance Apart](/solution/0300-0399/0358.Rearrange%20String%20k%20Distance%20Apart/README_EN.md) | `Greedy`,`Hash Table`,`String`,`Counting`,`Sorting`,`Heap (Priority Queue)` | Hard | 🔒 | +| 0359 | [Logger Rate Limiter](/solution/0300-0399/0359.Logger%20Rate%20Limiter/README_EN.md) | `Design`,`Hash Table`,`Data Stream` | Easy | 🔒 | | 0360 | [Sort Transformed Array](/solution/0300-0399/0360.Sort%20Transformed%20Array/README_EN.md) | `Array`,`Math`,`Two Pointers`,`Sorting` | Medium | 🔒 | | 0361 | [Bomb Enemy](/solution/0300-0399/0361.Bomb%20Enemy/README_EN.md) | `Array`,`Dynamic Programming`,`Matrix` | Medium | 🔒 | | 0362 | [Design Hit Counter](/solution/0300-0399/0362.Design%20Hit%20Counter/README_EN.md) | `Design`,`Queue`,`Array`,`Binary Search`,`Data Stream` | Medium | 🔒 | @@ -3382,16 +3383,16 @@ Press Control + F(or Command + F on | 3372 | [Maximize the Number of Target Nodes After Connecting Trees I](/solution/3300-3399/3372.Maximize%20the%20Number%20of%20Target%20Nodes%20After%20Connecting%20Trees%20I/README_EN.md) | `Tree`,`Depth-First Search`,`Breadth-First Search` | Medium | Weekly Contest 426 | | 3373 | [Maximize the Number of Target Nodes After Connecting Trees II](/solution/3300-3399/3373.Maximize%20the%20Number%20of%20Target%20Nodes%20After%20Connecting%20Trees%20II/README_EN.md) | `Tree`,`Depth-First Search`,`Breadth-First Search` | Hard | Weekly Contest 426 | | 3374 | [First Letter Capitalization II](/solution/3300-3399/3374.First%20Letter%20Capitalization%20II/README_EN.md) | `Database` | Hard | | -| 3375 | [Minimum Operations to Make Array Values Equal to K](/solution/3300-3399/3375.Minimum%20Operations%20to%20Make%20Array%20Values%20Equal%20to%20K/README_EN.md) | | Easy | Biweekly Contest 145 | -| 3376 | [Minimum Time to Break Locks I](/solution/3300-3399/3376.Minimum%20Time%20to%20Break%20Locks%20I/README_EN.md) | | Medium | Biweekly Contest 145 | -| 3377 | [Digit Operations to Make Two Integers Equal](/solution/3300-3399/3377.Digit%20Operations%20to%20Make%20Two%20Integers%20Equal/README_EN.md) | | Medium | Biweekly Contest 145 | -| 3378 | [Count Connected Components in LCM Graph](/solution/3300-3399/3378.Count%20Connected%20Components%20in%20LCM%20Graph/README_EN.md) | | Hard | Biweekly Contest 145 | -| 3379 | [Transformed Array](/solution/3300-3399/3379.Transformed%20Array/README_EN.md) | | Easy | Weekly Contest 427 | -| 3380 | [Maximum Area Rectangle With Point Constraints I](/solution/3300-3399/3380.Maximum%20Area%20Rectangle%20With%20Point%20Constraints%20I/README_EN.md) | | Medium | Weekly Contest 427 | -| 3381 | [Maximum Subarray Sum With Length Divisible by K](/solution/3300-3399/3381.Maximum%20Subarray%20Sum%20With%20Length%20Divisible%20by%20K/README_EN.md) | | Medium | Weekly Contest 427 | -| 3382 | [Maximum Area Rectangle With Point Constraints II](/solution/3300-3399/3382.Maximum%20Area%20Rectangle%20With%20Point%20Constraints%20II/README_EN.md) | | Hard | Weekly Contest 427 | -| 3383 | [Minimum Runes to Add to Cast Spell](/solution/3300-3399/3383.Minimum%20Runes%20to%20Add%20to%20Cast%20Spell/README_EN.md) | | Hard | 🔒 | -| 3384 | [Team Dominance by Pass Success](/solution/3300-3399/3384.Team%20Dominance%20by%20Pass%20Success/README_EN.md) | | Hard | 🔒 | +| 3375 | [Minimum Operations to Make Array Values Equal to K](/solution/3300-3399/3375.Minimum%20Operations%20to%20Make%20Array%20Values%20Equal%20to%20K/README_EN.md) | `Array`,`Hash Table` | Easy | Biweekly Contest 145 | +| 3376 | [Minimum Time to Break Locks I](/solution/3300-3399/3376.Minimum%20Time%20to%20Break%20Locks%20I/README_EN.md) | `Bit Manipulation`,`Array`,`Dynamic Programming`,`Backtracking`,`Bitmask` | Medium | Biweekly Contest 145 | +| 3377 | [Digit Operations to Make Two Integers Equal](/solution/3300-3399/3377.Digit%20Operations%20to%20Make%20Two%20Integers%20Equal/README_EN.md) | `Graph`,`Math`,`Number Theory`,`Shortest Path`,`Heap (Priority Queue)` | Medium | Biweekly Contest 145 | +| 3378 | [Count Connected Components in LCM Graph](/solution/3300-3399/3378.Count%20Connected%20Components%20in%20LCM%20Graph/README_EN.md) | `Union Find`,`Array`,`Hash Table`,`Math`,`Number Theory` | Hard | Biweekly Contest 145 | +| 3379 | [Transformed Array](/solution/3300-3399/3379.Transformed%20Array/README_EN.md) | `Array`,`Simulation` | Easy | Weekly Contest 427 | +| 3380 | [Maximum Area Rectangle With Point Constraints I](/solution/3300-3399/3380.Maximum%20Area%20Rectangle%20With%20Point%20Constraints%20I/README_EN.md) | `Binary Indexed Tree`,`Segment Tree`,`Geometry`,`Array`,`Math`,`Enumeration`,`Sorting` | Medium | Weekly Contest 427 | +| 3381 | [Maximum Subarray Sum With Length Divisible by K](/solution/3300-3399/3381.Maximum%20Subarray%20Sum%20With%20Length%20Divisible%20by%20K/README_EN.md) | `Array`,`Hash Table`,`Prefix Sum` | Medium | Weekly Contest 427 | +| 3382 | [Maximum Area Rectangle With Point Constraints II](/solution/3300-3399/3382.Maximum%20Area%20Rectangle%20With%20Point%20Constraints%20II/README_EN.md) | `Binary Indexed Tree`,`Segment Tree`,`Geometry`,`Array`,`Math`,`Sorting` | Hard | Weekly Contest 427 | +| 3383 | [Minimum Runes to Add to Cast Spell](/solution/3300-3399/3383.Minimum%20Runes%20to%20Add%20to%20Cast%20Spell/README_EN.md) | `Depth-First Search`,`Breadth-First Search`,`Graph`,`Topological Sort`,`Array` | Hard | 🔒 | +| 3384 | [Team Dominance by Pass Success](/solution/3300-3399/3384.Team%20Dominance%20by%20Pass%20Success/README_EN.md) | `Database` | Hard | 🔒 | ## Copyright