
算法
算法
qq_16298769
学习之路,长路漫漫,写学习笔记的过程就是把自己学会的东西讲给自己听的过程。在这个过程中,我们去记录思考的过程,便于日后的复习,梳理自己的思路。学习之了,独乐乐,不如众乐乐,把知识讲给更多的人听何乐而不为呢?
展开
-
堆
Java 实现 一般使用默认的优先队列。可供选择:BinaryHeap 大顶堆 PriorityQueue<Integer> maxHeap = new PriorityQueue<Integer>( (o1, o2) -> o2 - o1); 小顶堆 PriorityQueue<Integer> maxHeap = new PriorityQueue<Integer>(); 原理 插入 把新增元素放到队尾。数组长度++。队尾元素向上原创 2020-11-25 15:45:03 · 83 阅读 · 0 评论 -
PlusOne总结
抄一篇算法题 题目如下 Given a non-empty array of digitsrepresenting a non-negative integer, incrementone to the integer. The digits are stored such that the most significant digit is at the head of the list, and each element in the array contains a single digit..原创 2020-07-28 23:07:45 · 144 阅读 · 0 评论 -
常见的算法优化
1.递归的优化 依据主定理进行优化原创 2020-07-19 22:24:19 · 148 阅读 · 0 评论 -
时间复杂度和空间复杂度的计算
时间复杂度分为以下几个级别 常数级时间复杂度O(1) /** * 时间复杂度O(1) * 无论多少次。只要跟输入次数n没关系,就是O(1)的时间复杂度。可以说是O(2),O(3).最终都是O(1)的复杂度 */ function calculate(n){ console.log(1); console.log(2); console.log(3; .... } O(n) for(var i = 0 ; i < n ;i++){ console.原创 2020-07-19 22:14:57 · 308 阅读 · 0 评论