🌓

关于IO :同步、异步、阻塞、非阻塞

“是时候好好理清那些重要的基础概念和系统知识了” ——很久之后,当你从泥泞的业务项目代码中脱身时,总是会这样想到。本文主要是对阅读过的一些好的博客文章做一个汇总整理(参考博客地址见文章末尾),为了查阅方便,以及防止哪天这些博客的文章意外不见 Table of Contents 前言 blocking IO non-blocking IO IO mult...

阅读全文

希尔排序

参考:https://baike.baidu.com/item/%E5%B8%8C%E5%B0%94%E6%8E%92%E5%BA%8F/3229428?fr=aladdin 1234567891011121314//希尔排序func shellSort(arr []int) {length := len(arr)for step := lengt...

阅读全文

冒泡+选择+插入 排序

1234567891011121314151617181920212223242526272829303132333435//冒泡排序func bubbleSort(arr []int) {length := len(arr)for i := 0; i < length; i++ {for j := 0; j < length...

阅读全文

常见排序之复杂度对比

排序算法 时间复杂度 空间复杂度 稳定性 排序方式 冒泡排序 O(_n_2) O(1) 稳定 In-place 选择排序 O(_n_2) O(1) 不稳定 In-place 插入排序 O(_n_2) O(1) 稳定 In-place 希尔排序 O(nlogn) O(1) 不稳定 In-place 归并排序 O(nlogn) O(n) 稳定 Out-place...

阅读全文

归并排序

参考:https://zhuanlan.zhihu.com/p/124356219 时间复杂度:O(nlogn)空间复杂度:O(n)稳定性:稳定 12345678910111213141516171819202122232425262728293031323334353637383940func mergeSort(arr []int) {temp...

阅读全文

堆排序

参考链接:https://www.cnblogs.com/chengxiao/p/6129630.html 123456789101112131415161718192021222324252627282930//堆排序func headSort(arr []int) {length := len(arr)for i := length/2 - 1...

阅读全文

K 个一组翻转链表

题目:https://leetcode-cn.com/problems/reverse-nodes-in-k-group/ 12345678910111213141516171819202122232425262728293031323334353637383940/** * Definition for singly-linked list. * type...

阅读全文

无重复字符的最长子串

题目:https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/ 12345678910111213141516171819202122232425262728func lengthOfLongestSubstring(s string) int {...

阅读全文

反转链表

题目: https://leetcode-cn.com/problems/reverse-linked-list/ 多指针 12345678910111213141516171819/** * Definition for singly-linked list. * type ListNode struct { * Val int * ...

阅读全文

快速排序

快排 哎,比想象中的花时间啊! 代码这东西,还是保持手感。唯手熟尔。 1234567891011121314151617181920212223242526272829func sortArray(nums []int) []int { start := 0 left := 0 right := len(nums) - 1 ...

阅读全文