当前位置:网站首页>2022.02.13 - NC002. sort
2022.02.13 - NC002. sort
2022-07-06 08:21:00 【A CAI continues to work hard】
List of articles
1. subject
2. Ideas
(1) Quick sort
- The most basic quick sort algorithm .
3. Code
public class Test {
public static void main(String[] args) {
}
}
class Solution {
public int[] MySort(int[] arr) {
sort(arr, 0, arr.length - 1);
return arr;
}
private void sort(int[] arr, int left, int right) {
if (left < right) {
int low = left;
int high = right;
int pivot = arr[low];
while (low < high) {
while (low < high && arr[high] >= pivot) {
high--;
}
arr[low] = arr[high];
while (low < high && arr[low] <= pivot) {
low++;
}
arr[high] = arr[low];
}
arr[low] = pivot;
sort(arr, left, low - 1);
sort(arr, low + 1, right);
}
}
}
边栏推荐
- flask返回文件下载
- Personalized online cloud database hybrid optimization system | SIGMOD 2022 selected papers interpretation
- MFC 给列表控件发送左键单击、双击、以及右键单击消息
- 面向个性化需求的在线云数据库混合调优系统 | SIGMOD 2022入选论文解读
- Colorlog结合logging打印有颜色的日志
- 根据csv文件某一列字符串中某个数字排序
- 远程存储访问授权
- Go learning notes (3) basic types and statements (2)
- Sanzi chess (C language)
- Oracle time display adjustment
猜你喜欢
指针进阶---指针数组,数组指针
08- [istio] istio gateway, virtual service and the relationship between them
Circular reference of ES6 module
3. File operation 3-with
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
"Designer universe" APEC design +: the list of winners of the Paris Design Award in France was recently announced. The winners of "Changsha world center Damei mansion" were awarded by the national eco
好用的TCP-UDP_debug工具下载和使用
Use Alibaba icon in uniapp
From monomer structure to microservice architecture, introduction to microservices
Ruffian Heng embedded bimonthly, issue 49
随机推荐
Leetcode question brushing (5.28) hash table
使用 TiDB Lightning 恢复 S3 兼容存储上的备份数据
hcip--mpls
NFT smart contract release, blind box, public offering technology practice -- contract
【云原生】手把手教你搭建ferry开源工单系统
[Yugong series] creation of 009 unity object of U3D full stack class in February 2022
"Designer universe": "benefit dimension" APEC public welfare + 2022 the latest slogan and the new platform will be launched soon | Asia Pacific Financial Media
Yyds dry goods inventory three JS source code interpretation eventdispatcher
华为云OBS文件上传下载工具类
IOT -- interpreting the four tier architecture of the Internet of things
Migrate data from SQL files to tidb
升级 TiDB Operator
Summary of phased use of sonic one-stop open source distributed cluster cloud real machine test platform
【T31ZL智能视频应用处理器资料】
leetcode刷题 (5.31) 字符串
2. File operation - write
[Yugong series] February 2022 U3D full stack class 011 unity section 1 mind map
Introduction to number theory (greatest common divisor, prime sieve, inverse element)
Wireshark grabs packets to understand its word TCP segment
Flash return file download