当前位置:网站首页>Daily question 1984 Minimum difference in student scores
Daily question 1984 Minimum difference in student scores
2022-07-05 05:42:00 【A big pigeon】
topic :
To give you one Subscript from 0 Start Array of integers for nums , among nums[i] It means the first one i A student's grade . I'll give you another integer k .
Select any... From the array k A student's grade , Make this k Between scores The highest and Lowest score Of Difference value achieve To minimize the .
Return possible Minimum difference
Explain :
class Solution:
def minimumDifference(self, nums: List[int], k: int) -> int:
nums.sort()
cc = [nums[i+k-1]-nums[i] for i in range(len(nums)-k+1)]
return min(cc)边栏推荐
- 浅谈JVM(面试常考)
- 过拟合与正则化
- Software test -- 0 sequence
- 每日一题-搜索二维矩阵ps二维数组的查找
- Reflection summary of Haut OJ freshmen on Wednesday
- Codeforces Round #732 (Div. 2) D. AquaMoon and Chess
- Use of room database
- Sword finger offer 58 - ii Rotate string left
- Light a light with stm32
- 7. Processing the input of multidimensional features
猜你喜欢

Corridor and bridge distribution (csp-s-2021-t1) popular problem solution

SAP method of modifying system table data

7. Processing the input of multidimensional features

Web APIs DOM node

Sword finger offer 04 Search in two-dimensional array

Sword finger offer 05 Replace spaces

浅谈JVM(面试常考)

Dynamic planning solution ideas and summary (30000 words)

Sword finger offer 53 - ii Missing numbers from 0 to n-1

CF1634 F. Fibonacci Additions
随机推荐
lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
【Jailhouse 文章】Look Mum, no VM Exits
[jailhouse article] jailhouse hypervisor
Time complexity and space complexity
Talking about JVM (frequent interview)
2022年贵州省职业院校技能大赛中职组网络安全赛项规程
Introduction to tools in TF-A
Pointnet++ learning
API related to TCP connection
Remote upgrade afraid of cutting beard? Explain FOTA safety upgrade in detail
Time of process
Sword finger offer 05 Replace spaces
In this indifferent world, light crying
每日一题-无重复字符的最长子串
Reflection summary of Haut OJ freshmen on Wednesday
How to adjust bugs in general projects ----- take you through the whole process by hand
Palindrome (csp-s-2021-palin) solution
Codeforces Round #715 (Div. 2) D. Binary Literature
Implement a fixed capacity stack
Sword finger offer 58 - ii Rotate string left