摘要: 题目连接:https://leetcode.cn/problems/sort-list/ 快排(使用快排容易超时,建议使用归并排序) func main(){ head:=&ListNode{} end:=head aaa:=0 for i:=0;i<6;i++{ if i%2==0{ aaa=i 阅读全文
posted @ 2022-06-21 22:31 知道了呀~ 阅读(104) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.cn/problems/3sum/ func threeSum(nums []int)[][]int{ ans:=make([][]int,0) len:=len(nums) if len<3{ return ans } sort.Ints(nums) for i: 阅读全文
posted @ 2022-06-21 17:59 知道了呀~ 阅读(145) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.cn/problems/two-sum/ func twoSum(nums []int, target int) []int { mp:=make(map[int]int,len(nums)) //某个数字出现的次数 for i := range nums { if 阅读全文
posted @ 2022-06-21 17:58 知道了呀~ 阅读(65) 评论(0) 推荐(0) 编辑
摘要: 常用的设计模式 单例、工厂、观察者、发布订阅、责任链、适配器等 // 单例模式 //单例模式保证系统特定的类或者是结构体对象只有一个实例,是保障系统//实例唯一性的重要手段。 // 饿汉式 //在类创建的时候就已经实例化好了对象,只实例化一次,是线程安全的 //实现: 1、通过init()函数实现 阅读全文
posted @ 2022-06-21 14:36 知道了呀~ 阅读(71) 评论(0) 推荐(0) 编辑