当前位置:网站首页>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);
}
}
}
边栏推荐
- Oracle time display adjustment
- Circuit breaker: use of hystrix
- 从 SQL 文件迁移数据到 TiDB
- Zhong Xuegao, who cannot be melted, cannot escape the life cycle of online celebrity products
- Chinese Remainder Theorem (Sun Tzu theorem) principle and template code
- What is the use of entering the critical point? How to realize STM32 single chip microcomputer?
- sys.argv
- LDAP Application Section (4) Jenkins Access
- Hungry for 4 years + Ali for 2 years: some conclusions and Thoughts on the road of research and development
- Epoll and IO multiplexing of redis
猜你喜欢

【云原生】手把手教你搭建ferry开源工单系统

What is the use of entering the critical point? How to realize STM32 single chip microcomputer?

Make learning pointer easier (3)

指针和数组笔试题解析

How to use information mechanism to realize process mutual exclusion, process synchronization and precursor relationship

ESP系列引脚說明圖匯總

Asia Pacific Financial Media | "APEC industry +" Western Silicon Valley invests 2trillion yuan in Chengdu Chongqing economic circle to catch up with Shanghai | stable strategy industry fund observatio

Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center

Fibonacci sequence

让学指针变得更简单(三)
随机推荐
leetcode刷题 (5.31) 字符串
Use br to back up tidb cluster data to S3 compatible storage
LDAP應用篇(4)Jenkins接入
你想知道的ArrayList知识都在这
Golang DNS write casually
3. File operation 3-with
File upload of DVWA range
MFC sends left click, double click, and right click messages to list controls
Fibonacci sequence
Migrate data from CSV files to tidb
将 NFT 设置为 ENS 个人资料头像的分步指南
Asia Pacific Financial Media | "APEC industry +" Western Silicon Valley invests 2trillion yuan in Chengdu Chongqing economic circle to catch up with Shanghai | stable strategy industry fund observatio
[Yugong series] February 2022 U3D full stack class 010 prefabricated parts
08- [istio] istio gateway, virtual service and the relationship between them
Use Alibaba icon in uniapp
Configuring OSPF load sharing for Huawei devices
How to use information mechanism to realize process mutual exclusion, process synchronization and precursor relationship
Let the bullets fly for a while
Summary of MySQL index failure scenarios
1. Color inversion, logarithmic transformation, gamma transformation source code - miniopencv from zero