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 的最大值 ...
随机推荐
- STM32F103: NRF24L01
看了两天的24l01的相关资料了,一直有点模糊,今天下午感觉有点懂了,在板子上调试成功了,但是还没进行通讯测试.stm32和arduino进行通信还没成功 ,:( 先把stm32的NRF24L01配置 ...
- SPI笔记
sclk(serial clock):串行时钟 MOSI(master out slave input) (master 主机) (slave 从机) MISO(master int slave ...
- gulp-rev 添加版本号
打开node_modules\gulp-rev\index.js 第144行 manifest[originalFile] = revisionedFile; 更新为: manifest[origin ...
- set, map, string, find(), string name[100],等的混合
Unrequited Love Time Limit: 16 Seconds Memory Limit: 131072 KB There are n single boys and m si ...
- mcake活动维护常见问题记录【pc端】 ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★
★ ★ ★ ★ ★ ★ ★ ★ ★ ★pc端问题及解决方法 ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ 问题一.pc.弹窗,背景兼容ie8的写法 ;;; -moz-opacity:.7;f ...
- dataGridView的使用经验
1.dataGridView是dataGrid的替代品,包含了dataGrid的全部功能. 2.为dataGridView赋值,一般将其数据设置为一个DataTabel.例子如下: DataTable ...
- 使用flowable 6.1.2 REST API 运行请假审批流程
一.下载 flowable rest war 包 http://download.csdn.net/detail/teamlet/9913312 二.部署 复制flowable REST.war到To ...
- H5 pattern
pattern:正则表达式验证 例如: <input pattern="1[3578]\d{9}"> 可以省略^和$ 必须和required配合使用,否则在用户没有输 ...
- 有效处理Java异常三原则
Java中异常提供了一种识别及响应错误情况的一致性机制,有效地异常处理能使程序更加健壮.易于调试.异常之所以是一种强大的调试手段,在于其回答了以下三个问题: 什么出了错? 在哪出的错? 为什么出错? ...
- 如何在公司Http代理后使用NuGet官方源
文章转自CSDN 霍力强的专栏 有些公司上网使用的是Http代理.默认情况下,VS是无法访问外部网络的.如果要使用NuGet,通常只能在局域网里架一个自己的NuGet服务器.但这种方法不论是packa ...