当前位置:网站首页>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;
}
边栏推荐
- Soem EtherCAT source code analysis II (list of known configuration information)
- 【论文阅读】2022年最新迁移学习综述笔注(Transferability in Deep Learning: A Survey)
- Example 003: a complete square is an integer. It is a complete square after adding 100, and it is a complete square after adding 168. What is the number?
- QEMU demo makefile analysis
- Measurement fitting based on Halcon learning [i] fuse Hdev routine
- [trio basic from introduction to mastery tutorial XIV] trio realizes unit axis multi-color code capture
- Weidongshan Internet of things learning lesson 1
- PMSM dead time compensation
- [paper reading] the latest transfer ability in deep learning: a survey in 2022
- Several important parameters of LDO circuit design and type selection
猜你喜欢
UE像素流,来颗“减肥药”吧!
99 multiplication table (C language)
实例007:copy 将一个列表的数据复制到另一个列表中。
Step motor generates S-curve upper computer
[trio basic tutorial 17 from getting started to mastering] set up and connect the trio motion controller and input the activation code
DokuWiki deployment notes
Semiconductor devices (I) PN junction
Halcon's practice based on shape template matching [2]
How to copy formatted notepad++ text?
【三层架构】
随机推荐
The firmware of the connected j-link does not support the following memory access
[tutorial 19 of trio basic from introduction to proficiency] detailed introduction of trio as a slave station connecting to the third-party bus (anybus PROFIBUS DP...)
Class of color image processing based on Halcon learning_ ndim_ norm. hdev
Semiconductor devices (III) FET
2020-05-21
QEMU demo makefile analysis
go依赖注入--google开源库wire
Negative pressure generation of buck-boost circuit
Arduino uses nrf24l01+ communication
Wifi-802.11 negotiation rate table
Example 001: the number combination has four numbers: 1, 2, 3, 4. How many three digits can be formed that are different from each other and have no duplicate numbers? How many are each?
Vofa+ software usage record
STM32 single chip microcomputer - external interrupt
What are the test items of power battery ul2580
Summary of SIM card circuit knowledge
Carrier period, electrical speed, carrier period variation
My-basic application 2: my-basic installation and operation
STM32---IIC
Live555 push RTSP audio and video stream summary (III) flower screen problem caused by pushing H264 real-time stream
Example 003: a complete square is an integer. It is a complete square after adding 100, and it is a complete square after adding 168. What is the number?