Skip to content

Commit 6696a97

Browse files
LetMeFly666Copilot
andauthored
update: 添加问题“3195.包含所有1的最小矩形面积I”的代码和题解 (#1093)
* archive: many days(words+837题解小改) Signed-off-by: LetMeFly666 <[email protected]> * 3195: WA.cpp (#1092) + docs(jp) + init * 3195: AC.cpp+WA.py (#1092) - 和CPP的WA原因一模一样 cpp - AC,64.89%,94.68% * 3195: AC.py+rs + LEETCODE - bug(#1092) - go写好快 py - AC,25.00%,81.25% rust - AC,40.00%,40.00% Compile timed out. Please try again. If the issue persists, please report it to us. * 3195: AC.go+CE.java (#1092) go - AC,68.42%,42.10% * 3195: AC.java (#1092) - java也写好快 java - AC,98.08%,84.62% * update: 添加问题“3195.包含所有1的最小矩形面积I”的代码和题解 (#1093) Signed-off-by: LetMeFly666 <[email protected]> * fix(words): (9个月前)拼写错误的日语单词 Update Solutions/Other-Japanese-LearningNotes.md Co-authored-by: Copilot <[email protected]> * typo: grid Update Solutions/LeetCode 3195.包含所有1的最小矩形面积I.md Co-authored-by: Copilot <[email protected]> * typo: 即为 Update Solutions/LeetCode 3195.包含所有1的最小矩形面积I.md Co-authored-by: Copilot <[email protected]> --------- Signed-off-by: LetMeFly666 <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent e5178bb commit 6696a97

13 files changed

+350
-16
lines changed

.commitmsg

Lines changed: 0 additions & 7 deletions
This file was deleted.

Codes/0837-new-21-game.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
* @Author: LetMeFly
33
* @Date: 2025-08-17 19:33:11
44
* @LastEditors: LetMeFly.xyz
5-
* @LastEditTime: 2025-08-17 22:31:00
5+
* @LastEditTime: 2025-08-17 22:55:04
66
*/
77
impl Solution {
88
pub fn new21_game(n: i32, k: i32, max_pts: i32) -> f64 {
99
let k: usize = k as usize;
1010
let max_pts: usize = max_pts as usize;
1111
let n: usize = n as usize;
1212

13-
let mut dp: Vec<f64> = vec![0 as f64; k + max_pts];
13+
let mut dp: Vec<f64> = vec![0.; k + max_pts];
1414
let mut s: f64 = 0.;
1515
for i in k..(k+max_pts) {
1616
if i <= n {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2025-08-22 21:18:33
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2025-08-22 21:21:31
6+
*/
7+
#if defined(_WIN32) || defined(__APPLE__)
8+
#include "_[1,2]toVector.h"
9+
#endif
10+
11+
class Solution {
12+
public:
13+
int minimumArea(vector<vector<int>>& grid) {
14+
int l = 1000, r = 0, u = 1000, d = 0;
15+
for (int i = 0; i < grid.size(); i++) {
16+
for (int j = 0; j < grid[i].size(); j++) {
17+
if (grid[i][j]) {
18+
l = min(l, j);
19+
r = max(r, j);
20+
u = min(u, i);
21+
d = max(d, i);
22+
}
23+
}
24+
}
25+
return (r - l + 1) * (d - u + 1);
26+
}
27+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2025-08-22 21:18:33
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2025-08-22 21:30:00
6+
*/
7+
package main
8+
9+
func minimumArea(grid [][]int) int {
10+
l, r, u, d := 1000, 0, 1000, 0
11+
for i, row := range grid {
12+
for j, g := range row {
13+
if g == 1 {
14+
l = min(l, j)
15+
r = max(r, j)
16+
u = min(u, i)
17+
d = max(d, i)
18+
}
19+
}
20+
}
21+
return (r - l + 1) * (d - u + 1)
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2025-08-22 21:18:33
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2025-08-22 21:33:05
6+
*/
7+
class Solution {
8+
public int minimumArea(int[][] grid) {
9+
int l = 1000, r = 0, u = 1000, d = 0;
10+
for (int i = 0; i < grid.length; i++) {
11+
for (int j = 0; j < grid[i].length; j++) {
12+
if (grid[i][j] == 1) {
13+
l = Math.min(l, j);
14+
r = Math.max(r, j);
15+
u = Math.min(u, i);
16+
d = Math.max(d, i);
17+
}
18+
}
19+
}
20+
return (r - l + 1) * (d - u + 1);
21+
}
22+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'''
2+
Author: LetMeFly
3+
Date: 2025-08-22 21:18:33
4+
LastEditors: LetMeFly.xyz
5+
LastEditTime: 2025-08-22 21:23:44
6+
'''
7+
from typing import List
8+
9+
class Solution:
10+
def minimumArea(self, grid: List[List[int]]) -> int:
11+
l = u = 1000
12+
r = d = 0
13+
for i, line in enumerate(grid):
14+
for j, g in enumerate(line):
15+
if g:
16+
l = min(l, j)
17+
r = max(r, j)
18+
u = min(u, i)
19+
d = max(d, i)
20+
return (r - l + 1) * (d - u + 1)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2025-08-22 21:18:33
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2025-08-22 21:28:08
6+
*/
7+
impl Solution {
8+
pub fn minimum_area(grid: Vec<Vec<i32>>) -> i32 {
9+
let mut l: usize = 1000;
10+
let mut r: usize = 0;
11+
let mut u: usize = 1000;
12+
let mut d: usize = 0;
13+
for (i, row) in grid.into_iter().enumerate() {
14+
for (j, g) in row.into_iter().enumerate() {
15+
if g == 1 {
16+
l = l.min(j);
17+
r = r.max(j);
18+
u = u.min(i);
19+
d = d.max(i);
20+
}
21+
}
22+
}
23+
((r - l + 1) * (d - u + 1)) as i32
24+
}
25+
}

Codes/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
* @LastEditTime: 2025-08-11 22:07:08
66
*/
77
pub struct Solution;
8-
include!("0837-new-21-game.rs"); // 这个fileName是会被脚本替换掉的
8+
include!("3195-find-the-minimum-area-to-cover-all-ones-i.rs"); // 这个fileName是会被脚本替换掉的

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,7 @@
965965
|3191.使二进制数组全部等于1的最少操作次数I|中等|<a href="https://leetcode.cn/problems/minimum-operations-to-make-binary-array-elements-equal-to-one-i/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2024/10/18/LeetCode%203191.%E4%BD%BF%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%95%B0%E7%BB%84%E5%85%A8%E9%83%A8%E7%AD%89%E4%BA%8E1%E7%9A%84%E6%9C%80%E5%B0%91%E6%93%8D%E4%BD%9C%E6%AC%A1%E6%95%B0I/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/143064645" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/minimum-operations-to-make-binary-array-elements-equal-to-one-i/solutions/2956198/letmefly-3191shi-er-jin-zhi-shu-zu-quan-n822o/" target="_blank">LeetCode题解</a>|
966966
|3192.使二进制数组全部等于1的最少操作次数II|中等|<a href="https://leetcode.cn/problems/minimum-operations-to-make-binary-array-elements-equal-to-one-ii/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2024/10/19/LeetCode%203192.%E4%BD%BF%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%95%B0%E7%BB%84%E5%85%A8%E9%83%A8%E7%AD%89%E4%BA%8E1%E7%9A%84%E6%9C%80%E5%B0%91%E6%93%8D%E4%BD%9C%E6%AC%A1%E6%95%B0II/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/143066863" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/minimum-operations-to-make-binary-array-elements-equal-to-one-ii/solutions/2956341/letmefly-3192shi-er-jin-zhi-shu-zu-quan-ih15d/" target="_blank">LeetCode题解</a>|
967967
|3194.最小元素和最大元素的最小平均值|简单|<a href="https://leetcode.cn/problems/minimum-average-of-smallest-and-largest-elements/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2024/10/16/LeetCode%203194.%E6%9C%80%E5%B0%8F%E5%85%83%E7%B4%A0%E5%92%8C%E6%9C%80%E5%A4%A7%E5%85%83%E7%B4%A0%E7%9A%84%E6%9C%80%E5%B0%8F%E5%B9%B3%E5%9D%87%E5%80%BC/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/142994095" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/minimum-average-of-smallest-and-largest-elements/solutions/2953616/letmefly-3194zui-xiao-yuan-su-he-zui-da-6f4v5/" target="_blank">LeetCode题解</a>|
968+
|3195.包含所有1的最小矩形面积I|中等|<a href="https://leetcode.cn/problems/find-the-minimum-area-to-cover-all-ones-i/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2025/08/22/LeetCode%203195.%E5%8C%85%E5%90%AB%E6%89%80%E6%9C%891%E7%9A%84%E6%9C%80%E5%B0%8F%E7%9F%A9%E5%BD%A2%E9%9D%A2%E7%A7%AFI/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/150618919" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/find-the-minimum-area-to-cover-all-ones-i/solutions/3760997/letmefly-3195bao-han-suo-you-1-de-zui-xi-6h6a/" target="_blank">LeetCode题解</a>|
968969
|3200.三角形的最大高度|简单|<a href="https://leetcode.cn/problems/maximum-height-of-a-triangle/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2024/10/15/LeetCode%203200.%E4%B8%89%E8%A7%92%E5%BD%A2%E7%9A%84%E6%9C%80%E5%A4%A7%E9%AB%98%E5%BA%A6/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/142967272" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/maximum-height-of-a-triangle/solutions/2952209/letmefly-3200san-jiao-xing-de-zui-da-gao-m23t/" target="_blank">LeetCode题解</a>|
969970
|3201.找出有效子序列的最大长度I|中等|<a href="https://leetcode.cn/problems/find-the-maximum-length-of-valid-subsequence-i/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2025/07/16/LeetCode%203201.%E6%89%BE%E5%87%BA%E6%9C%89%E6%95%88%E5%AD%90%E5%BA%8F%E5%88%97%E7%9A%84%E6%9C%80%E5%A4%A7%E9%95%BF%E5%BA%A6I/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/149409629" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/find-the-maximum-length-of-valid-subsequence-i/solutions/3725834/letmefly-3201zhao-chu-you-xiao-zi-xu-lie-3quj/" target="_blank">LeetCode题解</a>|
970971
|3202.找出有效子序列的最大长度II|中等|<a href="https://leetcode.cn/problems/find-the-maximum-length-of-valid-subsequence-ii/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2025/07/18/LeetCode%203202.%E6%89%BE%E5%87%BA%E6%9C%89%E6%95%88%E5%AD%90%E5%BA%8F%E5%88%97%E7%9A%84%E6%9C%80%E5%A4%A7%E9%95%BF%E5%BA%A6II/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/149491839" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/find-the-maximum-length-of-valid-subsequence-ii/solutions/3729058/letmefly-3202zhao-chu-you-xiao-zi-xu-lie-9eyq/" target="_blank">LeetCode题解</a>|

Solutions/LeetCode 0837.新21点.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ impl Solution {
208208
let max_pts: usize = max_pts as usize;
209209
let n: usize = n as usize;
210210

211-
let mut dp: Vec<f64> = vec![0 as f64; k + max_pts];
211+
let mut dp: Vec<f64> = vec![0.; k + max_pts];
212212
let mut s: f64 = 0.;
213213
for i in k..(k+max_pts) {
214214
if i <= n {

0 commit comments

Comments
 (0)