当前位置:网站首页>2022.7.4-----leetcode.1200
2022.7.4-----leetcode.1200
2022-07-05 08:22:00 【路Lu727】
public List<List<Integer>> minimumAbsDifference(int[] arr) {
int n=arr.length;
List<List<Integer>> ans=new ArrayList<>();
Arrays.sort(arr);
int min=Integer.MAX_VALUE;
for(int i=1;i<n;i++){
if(arr[i]-arr[i-1]<min){
ans.clear();
List<Integer> tmp=new ArrayList<>();
tmp.add(arr[i-1]);
tmp.add(arr[i]);
ans.add(tmp);
min=arr[i]-arr[i-1];
}else if(arr[i]-arr[i-1]==min){
List<Integer> tmp=new ArrayList<>();
tmp.add(arr[i-1]);
tmp.add(arr[i]);
ans.add(tmp);
}
}
return ans;
}边栏推荐
- Tailq of linked list
- 实例006:斐波那契数列
- go依赖注入--google开源库wire
- Detailed summary of FIO test hard disk performance parameters and examples (with source code)
- Problem solving: interpreter error: no file or directory
- Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine
- Hardware 1 -- relationship between gain and magnification
- C WinForm [realize the previous and next selection pictures] - practice 7
- 动力电池UL2580测试项目包括哪些
- Example 002: the bonus paid by the "individual income tax calculation" enterprise is based on the profit commission. When the profit (I) is less than or equal to 100000 yuan, the bonus can be increase
猜你喜欢

Shell script
![Measurement fitting based on Halcon learning [i] fuse Hdev routine](/img/91/34c92065e797c87d6ce5ea13903993.jpg)
Measurement fitting based on Halcon learning [i] fuse Hdev routine

STM32 --- NVIC interrupt

STM32---IIC

Why is 1900 not a leap year

QEMU STM32 vscode debugging environment configuration

Solutions to compilation warnings in Quartus II
![Shape template matching based on Halcon learning [vi] find_ mirror_ dies. Hdev routine](/img/99/21c228ff5de46c4a42b60f989b10e8.jpg)
Shape template matching based on Halcon learning [vi] find_ mirror_ dies. Hdev routine

STM32 single chip microcomputer -- debug in keil5 cannot enter the main function
![Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine](/img/f9/fc4f0bbce36b3c1368d838d723b027.jpg)
Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine
随机推荐
实例007:copy 将一个列表的数据复制到另一个列表中。
实例004:这天第几天 输入某年某月某日,判断这一天是这一年的第几天?
Sizeof (function name) =?
PMSM dead time compensation
[trio basic from introduction to mastery tutorial 20] trio calculates the arc center and radius through three points of spatial arc
Shape template matching based on Halcon learning [VII] reuse_ model. Hdev routine
QEMU STM32 vscode debugging environment configuration
实例002:“个税计算” 企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.
Slist of linked list
Hardware 1 -- relationship between gain and magnification
MHA High available Cluster for MySQL
Shape template matching based on Halcon learning [viii] PM_ multiple_ models. Hdev routine
關於線性穩壓器的五個設計細節
General makefile (I) single C language compilation template
Compilation warning solution sorting in Quartus II
Carrier period, electrical speed, carrier period variation
Adaptive filter
Live555 RTSP audio and video streaming summary (II) modify RTSP server streaming URL address
Soem EtherCAT source code analysis I (data type definition)
Solutions to compilation warnings in Quartus II