当前位置:网站首页>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)
- Measurement fitting based on Halcon learning [II] meaure_ pin. Hdev routine
- [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...)
- Bluetooth hc-05 pairing process and precautions
- Bluebridge cup internet of things basic graphic tutorial - GPIO output control LD5 on and off
- How to write cover letter?
- Soem EtherCAT source code analysis I (data type definition)
- Detailed explanation of SQL server stored procedures
- Naming rules for FreeRTOS
- [trio basic tutorial 17 from getting started to mastering] set up and connect the trio motion controller and input the activation code
猜你喜欢
Let's briefly talk about the chips commonly used in mobile phones - OVP chips
[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...)
MHA High available Cluster for MySQL
Arduino uses nrf24l01+ communication
实例008:九九乘法表
Why is 1900 not a leap year
[three tier architecture]
Introduction of air gap, etc
leetcode - 445. 两数相加 II
Several implementation schemes of anti reverse connection protection of positive and negative poles of power supply!
随机推荐
Design a clock frequency division circuit that can be switched arbitrarily
Let's briefly talk about the chips commonly used in mobile phones - OVP chips
[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication
Working principle and type selection of common mode inductor
【三层架构】
Sql Server的存儲過程詳解
Shell script
Negative pressure generation of buck-boost circuit
Installation and use of libjpeg and ligpng
实例006:斐波那契数列
Stm32--- systick timer
Measurement fitting based on Halcon learning [i] fuse Hdev routine
Naming rules for FreeRTOS
MHA High available Cluster for MySQL
Soem EtherCAT source code analysis I (data type definition)
STM32 tutorial triple ADC interleaved sampling
Summary of SIM card circuit knowledge
FIO测试硬盘性能参数和实例详细总结(附源码)
剑指 Offer 09. 用两个栈实现队列
[three tier architecture]