feat: 2025-10-24打卡

This commit is contained in:
wu xiangkai
2025-10-24 11:28:01 +08:00
parent d0478198a9
commit 9639d043e8
8 changed files with 338 additions and 0 deletions

26
908.smallest-range-i.java Normal file
View File

@@ -0,0 +1,26 @@
/*
* @lc app=leetcode id=908 lang=java
*
* [908] Smallest Range I
*/
// @lc code=start
class Solution {
public int smallestRangeI(int[] nums, int k) {
if(nums == null || nums.length == 0) {
return 0;
}
int min = nums[0], max = nums[0];
for(int i = 1; i < nums.length; i++) {
if(nums[i] < min) {
min = nums[i];
}
if(nums[i] > max) {
max = nums[i];
}
}
return max - min > 2 * k ? max - min - 2 * k : 0;
}
}
// @lc code=end