Skip to content

Commit 99f4ad6

Browse files
committed
update: 添加问题“1984.学生分数的最小差值”的代码和题解 (#1347)
今天: 1984: AC.cpp+py+go+java+rust (#1346) + word: en(jp) cpp - AC,100.00%,33.57% WA.py py - AC,84.93%,7.24% WA.go go - AC,28.13%,20.31% java - AC,83.61%,5.02% rust - AC,100.00%,76.47% --- 昨天: 1877: AC.cpp+java+rust+py+go (#1344) cpp - AC,74.40%,21.43% py - AC,9.40%,17.09% py - AC,63.25%,7.69%,len()/2 py - AC,51.28%,11.97% - [~i] go - AC,44.44%,44.44% rust - AC,50.00%,50.00% java - AC,20.00%,10.00% Signed-off-by: LetMeFly666 <814114971@qq.com>
1 parent 315e9ba commit 99f4ad6

13 files changed

Lines changed: 315 additions & 3 deletions

.commitmsg

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
今天:
2+
3+
1984: AC.cpp+py+go+java+rust (#1346) + word: en(jp)
4+
5+
cpp - AC,100.00%,33.57%
6+
WA.py
7+
py - AC,84.93%,7.24%
8+
WA.go
9+
go - AC,28.13%,20.31%
10+
java - AC,83.61%,5.02%
11+
rust - AC,100.00%,76.47%
12+
13+
---
14+
15+
昨天:
16+
17+
1877: AC.cpp+java+rust+py+go (#1344)
18+
19+
cpp - AC,74.40%,21.43%
20+
py - AC,9.40%,17.09%
21+
py - AC,63.25%,7.69%,len()/2
22+
py - AC,51.28%,11.97% - [~i]
23+
go - AC,44.44%,44.44%
24+
rust - AC,50.00%,50.00%
25+
java - AC,20.00%,10.00%
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2026-01-25 10:32:52
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2026-01-25 10:33:04
6+
*/
7+
#if defined(_WIN32) || defined(__APPLE__)
8+
#include "_[1,2]toVector.h"
9+
#endif
10+
11+
class Solution {
12+
public:
13+
int minimumDifference(vector<int>& nums, int k) {
14+
sort(nums.begin(), nums.end());
15+
int ans = 100000;
16+
for (int i = 0; i + k - 1 < nums.size(); i++) {
17+
ans = min(ans, nums[i + k - 1] - nums[i]);
18+
}
19+
return ans;
20+
}
21+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2026-01-25 10:32:52
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2026-01-25 10:39:42
6+
*/
7+
package main
8+
9+
import "sort"
10+
11+
// THIS CANNOT BE ACCEPTED
12+
func minimumDifference(nums []int, k int) (ans int) {
13+
sort.Ints(nums)
14+
for i := 0; i < len(nums) - k + 1; i++ {
15+
ans = min(ans, nums[i + k - 1] - nums[i])
16+
}
17+
return
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2026-01-25 10:32:52
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2026-01-25 10:40:30
6+
*/
7+
import java.util.Arrays;
8+
9+
class Solution {
10+
public int minimumDifference(int[] nums, int k) {
11+
int ans = 100000;
12+
Arrays.sort(nums);
13+
for (int i = 0; i + k - 1 < nums.length; i++) {
14+
ans = Math.min(ans, nums[i + k - 1] - nums[i]);
15+
}
16+
return ans;
17+
}
18+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'''
2+
Author: LetMeFly
3+
Date: 2026-01-25 10:32:52
4+
LastEditors: LetMeFly.xyz
5+
LastEditTime: 2026-01-25 10:35:25
6+
'''
7+
from typing import List
8+
9+
# THIS CANNOT BE ACCEPTED
10+
class Solution:
11+
def minimumDifference(self, nums: List[int], k: int) -> int:
12+
nums.sort()
13+
return max(nums[i + k - 1] - nums[i] for i in range(len(nums) - k + 1))
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2026-01-25 10:32:52
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2026-01-25 10:43:39
6+
*/
7+
impl Solution {
8+
pub fn minimum_difference(mut nums: Vec<i32>, k: i32) -> i32 {
9+
let k = k as usize;
10+
let mut ans = 100000;
11+
nums.sort();
12+
for i in 0..nums.len() - k + 1 {
13+
ans = ans.min(nums[i + k - 1] - nums[i]);
14+
}
15+
ans
16+
}
17+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2026-01-25 10:32:52
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2026-01-25 10:39:56
6+
*/
7+
package main
8+
9+
import "sort"
10+
11+
func minimumDifference(nums []int, k int) int {
12+
ans := 100000
13+
sort.Ints(nums)
14+
for i := 0; i < len(nums) - k + 1; i++ {
15+
ans = min(ans, nums[i + k - 1] - nums[i])
16+
}
17+
return ans
18+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'''
2+
Author: LetMeFly
3+
Date: 2026-01-25 10:32:52
4+
LastEditors: LetMeFly.xyz
5+
LastEditTime: 2026-01-25 10:37:04
6+
'''
7+
from typing import List
8+
9+
class Solution:
10+
def minimumDifference(self, nums: List[int], k: int) -> int:
11+
nums.sort()
12+
return min(nums[i + k - 1] - nums[i] for i in range(len(nums) - k + 1))

Codes/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @LastEditTime: 2026-01-06 13:17:16
66
*/
77
pub struct Solution;
8-
include!("1877-minimize-maximum-pair-sum-in-array_20260124.rs"); // 这个fileName是会被脚本替换掉的
8+
include!("1984-minimum-difference-between-highest-and-lowest-of-k-scores_20260125.rs"); // 这个fileName是会被脚本替换掉的
99

1010
#[derive(Debug, PartialEq, Eq)]
1111
pub struct TreeNode {

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Author: LetMeFly
33
* @Date: 2022-05-19 18:48:53
44
* @LastEditors: LetMeFly.xyz
5-
* @LastEditTime: 2026-01-10 23:52:24
5+
* @LastEditTime: 2026-01-25 10:28:16
66
-->
77
# LetLeet Blog
88

@@ -678,7 +678,7 @@
678678
|1857.有向图中最大颜色值|困难|<a href="https://leetcode.cn/problems/largest-color-value-in-a-directed-graph/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2025/05/26/LeetCode%201857.%E6%9C%89%E5%90%91%E5%9B%BE%E4%B8%AD%E6%9C%80%E5%A4%A7%E9%A2%9C%E8%89%B2%E5%80%BC/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/148242411" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/largest-color-value-in-a-directed-graph/solutions/3686868/letmefly-1857you-xiang-tu-zhong-zui-da-y-6wj6/" target="_blank">LeetCode题解</a>|
679679
|1863.找出所有子集的异或总和再求和|简单|<a href="https://leetcode.cn/problems/sum-of-all-subset-xor-totals/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2025/04/06/LeetCode%201863.%E6%89%BE%E5%87%BA%E6%89%80%E6%9C%89%E5%AD%90%E9%9B%86%E7%9A%84%E5%BC%82%E6%88%96%E6%80%BB%E5%92%8C%E5%86%8D%E6%B1%82%E5%92%8C/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/147027120" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/sum-of-all-subset-xor-totals/solutions/3642017/letmefly-1863zhao-chu-suo-you-zi-ji-de-y-a02c/" target="_blank">LeetCode题解</a>|
680680
|1870.准时到达的列车最小时速|中等|<a href="https://leetcode.cn/problems/minimum-speed-to-arrive-on-time/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2024/10/02/LeetCode%201870.%E5%87%86%E6%97%B6%E5%88%B0%E8%BE%BE%E7%9A%84%E5%88%97%E8%BD%A6%E6%9C%80%E5%B0%8F%E6%97%B6%E9%80%9F/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/142680612" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/minimum-speed-to-arrive-on-time/solutions/2937033/letmefly-1870zhun-shi-dao-da-de-lie-che-liv8g/" target="_blank">LeetCode题解</a>|
681-
|1877.数组中最大数对和的最小值|中等|<a href="https://leetcode.cn/problems/minimize-maximum-pair-sum-in-array/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2026/01/24/LeetCode%201877.%E6%95%B0%E7%BB%84%E4%B8%AD%E6%9C%80%E5%A4%A7%E6%95%B0%E5%AF%B9%E5%92%8C%E7%9A%84%E6%9C%80%E5%B0%8F%E5%80%BC/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/157333871" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/minimize-maximum-pair-sum-in-array/solutions/3888328/letmefly-1877shu-zu-zhong-zui-da-shu-dui-yxqi/" target="_blank">LeetCode题解</a>|
681+
|1877.数组中最大数对和的最小值|中等|<a href="https://leetcode.cn/problems/minimize-maximum-pair-sum-in-array/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2026/01/24/LeetCode%201877.%E6%95%B0%E7%BB%84%E4%B8%AD%E6%9C%80%E5%A4%A7%E6%95%B0%E5%AF%B9%E5%92%8C%E7%9A%84%E6%9C%80%E5%B0%8F%E5%80%BC/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/157333871" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/minimize-maximum-pair-sum-in-array/solutions/3888405/letmefly-1877shu-zu-zhong-zui-da-shu-dui-sm70/" target="_blank">LeetCode题解</a>|
682682
|1884.鸡蛋掉落-两枚鸡蛋|中等|<a href="https://leetcode.cn/problems/egg-drop-with-2-eggs-and-n-floors/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2024/10/13/LeetCode%201884.%E9%B8%A1%E8%9B%8B%E6%8E%89%E8%90%BD-%E4%B8%A4%E6%9E%9A%E9%B8%A1%E8%9B%8B/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/142906976" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/egg-drop-with-2-eggs-and-n-floors/solutions/2949710/letmefly-1884ji-dan-diao-luo-liang-mei-j-saz6/" target="_blank">LeetCode题解</a>|
683683
|1895.最大的幻方|中等|<a href="https://leetcode.cn/problems/largest-magic-square/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2026/01/18/LeetCode%201895.%E6%9C%80%E5%A4%A7%E7%9A%84%E5%B9%BB%E6%96%B9/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/157104818" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/largest-magic-square/solutions/3883805/letmefly-1895zui-da-de-huan-fang-bao-li-9ln7k/" target="_blank">LeetCode题解</a>|
684684
|1901.寻找峰值II|中等|<a href="https://leetcode.cn/problems/find-a-peak-element-ii/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2023/12/19/LeetCode%201901.%E5%AF%BB%E6%89%BE%E5%B3%B0%E5%80%BCII/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/135083347" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/find-a-peak-element-ii/solutions/2572012/letmefly-1901xun-zhao-feng-zhi-iier-fen-19tmj/" target="_blank">LeetCode题解</a>|
@@ -701,6 +701,7 @@
701701
|1971.寻找图中是否存在路径|简单|<a href="https://leetcode.cn/problems/find-if-path-exists-in-graph/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2022/12/19/LeetCode%201971.%E5%AF%BB%E6%89%BE%E5%9B%BE%E4%B8%AD%E6%98%AF%E5%90%A6%E5%AD%98%E5%9C%A8%E8%B7%AF%E5%BE%84/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/128377260" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/find-if-path-exists-in-graph/solutions/2026262/letmefly-1971xun-zhao-tu-zhong-shi-fou-c-uunl/" target="_blank">LeetCode题解</a>|
702702
|1975.最大方阵和|中等|<a href="https://leetcode.cn/problems/maximum-matrix-sum/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2026/01/05/LeetCode%201975.%E6%9C%80%E5%A4%A7%E6%96%B9%E9%98%B5%E5%92%8C/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/156614059" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/maximum-matrix-sum/solutions/3873474/letmefly-1975zui-da-fang-zhen-he-nao-jin-j6w7/" target="_blank">LeetCode题解</a>|
703703
|1976.到达目的地的方案数|中等|<a href="https://leetcode.cn/problems/number-of-ways-to-arrive-at-destination/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2024/03/05/LeetCode%201976.%E5%88%B0%E8%BE%BE%E7%9B%AE%E7%9A%84%E5%9C%B0%E7%9A%84%E6%96%B9%E6%A1%88%E6%95%B0/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/136481215" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/number-of-ways-to-arrive-at-destination/" target="_blank">LeetCode题解</a>|
704+
|1984.学生分数的最小差值|简单|<a href="https://leetcode.cn/problems/minimum-difference-between-highest-and-lowest-of-k-scores/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2026/01/25/LeetCode%201984.%E5%AD%A6%E7%94%9F%E5%88%86%E6%95%B0%E7%9A%84%E6%9C%80%E5%B0%8F%E5%B7%AE%E5%80%BC/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/157362645" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/minimum-difference-between-highest-and-lowest-of-k-scores/solutions/3888715/letmefly-1984xue-sheng-fen-shu-de-zui-xi-3qnw/" target="_blank">LeetCode题解</a>|
704705
|1993.树上的操作|中等|<a href="https://leetcode.cn/problems/operations-on-tree/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2023/09/23/LeetCode%201993.%E6%A0%91%E4%B8%8A%E7%9A%84%E6%93%8D%E4%BD%9C/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/133198960" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/operations-on-tree/solutions/2455220/letmefly-1993shu-shang-de-cao-zuo-da-mo-1n5vz/" target="_blank">LeetCode题解</a>|
705706
|1997.访问完所有房间的第一天|中等|<a href="https://leetcode.cn/problems/first-day-where-you-have-been-in-all-the-rooms/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2024/03/28/LeetCode%201997.%E8%AE%BF%E9%97%AE%E5%AE%8C%E6%89%80%E6%9C%89%E6%88%BF%E9%97%B4%E7%9A%84%E7%AC%AC%E4%B8%80%E5%A4%A9/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/137119523" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/first-day-where-you-have-been-in-all-the-rooms/solutions/2712786/letmefly-1997fang-wen-wan-suo-you-fang-j-6nrr/" target="_blank">LeetCode题解</a>|
706707
|2007.从双倍数组中还原原数组|中等|<a href="https://leetcode.cn/problems/find-original-array-from-doubled-array/" target="_blank">题目地址</a>|<a href="https://blog.letmefly.xyz/2024/04/18/LeetCode%202007.%E4%BB%8E%E5%8F%8C%E5%80%8D%E6%95%B0%E7%BB%84%E4%B8%AD%E8%BF%98%E5%8E%9F%E5%8E%9F%E6%95%B0%E7%BB%84/" target="_blank">题解地址</a>|<a href="https://letmefly.blog.csdn.net/article/details/137924488" target="_blank">CSDN题解</a>|<a href="https://leetcode.cn/problems/find-original-array-from-doubled-array/solutions/2745715/letmefly-2007cong-shuang-bei-shu-zu-zhon-o8uy/" target="_blank">LeetCode题解</a>|

0 commit comments

Comments
 (0)