class Solution {
public:
int smallestRangeI(vector<int>& A, int K) {
if(A.size() == 1 || A.size() == 0)
{
return 0;
}
sort(A.begin(),A.end());
int index = A.size()-1;
if(2*K>(A[index]-A[0]))
return 0;
return (A[index]-K) - (A[0]+K);
}
};
最小差值 I
猜你喜欢
转载自blog.csdn.net/C1029323236/article/details/89036782
今日推荐
周排行