当前位置:网站首页>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);
}
}
}
边栏推荐
- Day29-t77 & t1726-2022-02-13-don't answer by yourself
- [Yugong series] February 2022 U3D full stack class 011 unity section 1 mind map
- Char to leading 0
- MFC 给列表控件发送左键单击、双击、以及右键单击消息
- leetcode刷题 (5.28) 哈希表
- 2022 Inner Mongolia latest water conservancy and hydropower construction safety officer simulation examination questions and answers
- 从 SQL 文件迁移数据到 TiDB
- vulnhub hackme: 1
- Résumé des diagrammes de description des broches de la série ESP
- 备份与恢复 CR 介绍
猜你喜欢
2. File operation - write
Chinese Remainder Theorem (Sun Tzu theorem) principle and template code
Uibehavior, a comprehensive exploration of ugui source code
[Yugong series] February 2022 U3D full stack class 011 unity section 1 mind map
wincc7.5下载安装教程(Win10系统)
NFT smart contract release, blind box, public offering technology practice -- contract
[research materials] 2021 Research Report on China's smart medical industry - Download attached
Wireshark grabs packets to understand its word TCP segment
Learn Arduino with examples
指针和数组笔试题解析
随机推荐
ESP series pin description diagram summary
On the day of resignation, jd.com deleted the database and ran away, and the programmer was sentenced
Golang DNS write casually
Introduction to backup and recovery Cr
CAD ARX 获取当前的视口设置
根据csv文件某一列字符串中某个数字排序
How to use information mechanism to realize process mutual exclusion, process synchronization and precursor relationship
将 NFT 设置为 ENS 个人资料头像的分步指南
[Yugong series] February 2022 U3D full stack class 010 prefabricated parts
升级 TiDB Operator
Huawei cloud OBS file upload and download tool class
A Closer Look at How Fine-tuning Changes BERT
Chinese Remainder Theorem (Sun Tzu theorem) principle and template code
flask返回文件下载
Summary of phased use of sonic one-stop open source distributed cluster cloud real machine test platform
【T31ZL智能视频应用处理器资料】
Char to leading 0
Day29-t77 & t1726-2022-02-13-don't answer by yourself
Nft智能合约发行,盲盒,公开发售技术实战--拼图篇
1202 character lookup