leetcode908
int smallestRangeI(vector<int>& A, int K) {
int min = INT_MAX;
int max = INT_MIN;
for (auto a : A)
{
if (min > a)
{
min = a;
}
if (max < a)
{
max = a;
}
}
int dif = max - min;
if (dif > * K)
{
return dif - * K;
}
else
{
return ;
}
}
leetcode908的更多相关文章
- [Swift]LeetCode908. 最小差值 I | Smallest Range I
Given an array A of integers, for each integer A[i] we may choose any x with -K <= x <= K, and ...
- Leetcode908.Smallest Range I最小差值1
给定一个整数数组 A,对于每个整数 A[i],我们可以选择任意 x 满足 -K <= x <= K,并将 x 加到 A[i] 中. 在此过程之后,我们得到一些数组 B. 返回 B 的最大值 ...
随机推荐
- WCF基础:绑定(一)
WCF中的终结点(ServiceEndpoint)包含有三要素:地址(EndpointAddress),绑定(Binding),契约描述(ContractDescription)三要素:其中绑定的在整 ...
- 自定义音频条形图--p52
package com.zzw.qunyingzhuan2; import android.content.Context; import android.graphics.Canvas; impor ...
- TCPL学习毕节:第六章hash表
对于P126的哈希表构成: struct nlist *install(char *name, char *defn) { struct nlist *np; unsigned hashval; if ...
- 2017.11.17 Demo-stm8+temperature timeing control
1Find the lab and add in project. Downtown it from ST official website..compile it to ensure it pa ...
- 移动元素时,translate要比margin好
比如 做全屏轮播时,父元素往往是被子元素撑起来的,那你设置父元素的margin时,往往会感染到子元素,如下图: 而用translate3d就不会出现这种效果:
- 21天学通C++_Day4
0.迭代器 昨天晚上3G移动通信实验的时候,需要写一些简单的C程序,用到for循环的时候,发现在不同的for循环中,若定义标识符相同的变量名时,会有报错,环境是VC6: 可是一想到在for语句声明的迭 ...
- Navicat for MySQL导入.sql文件
首先,打开Navicat for MySQL,打开需要使用的连接,新建一个数据库名等按自己的需求填写. 打开创建的数据库,在空白处右键,选择运行SQL文件,然后找到.SQL文件所在地址即可. MySQ ...
- iOS6和iOS7代码的适配(5)——popOver
popOver这个空间本身是iPad only的,所以iPhone上见不到,我记得微信上有个这样的弹出框,有扫一扫等几个菜单项,估计这是腾讯自己实现的,用于菜单的扩展. popOver从iOS6到iO ...
- hadoop1.x和2.x的一些主要区别
当我们安装完毕hadoop2的时候,我们看到为啥没有jobtracker,这是因为hadoop2中已经没有jobtracer了,而是产生了yarn,yarn是什么那,可以看yarn详解,我们为什么已经 ...
- CSS命名规范参考及书写注意事项
CSS书写顺序 *{ /*显示属性*/ display position float clear cursor … /*盒模型*/ margin padding width height /*排版*/ ...