摘要:
题目描述 输入n个整数,找出其中最小的K个数。例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,。 最下topk,使用大顶堆 public ArrayList<Integer> GetLeastNumbers_Solution(int [] input, int k 阅读全文
posted @ 2019-06-13 21:40
月半榨菜
阅读(85)
评论(0)
推荐(0)
摘要:
1. 前序遍历 (1)递归写法 (2)非递归写法 2.中序遍历 (1) 递归 (2)非递归 3.后序遍历 (1)递归 (2)非递归 4. 层次遍历 相关题 LeetCode144. Binary Tree Preorder Traversal LeetCode94. Binary Tree Inor 阅读全文
posted @ 2019-06-13 20:16
月半榨菜
阅读(137)
评论(0)
推荐(0)
摘要:
Given an array of integers nums, sort the array in ascending order. Example 1: Example 2: Note: 排序 参考https://www.cnblogs.com/zhacai/p/11011961.html 阅读全文
posted @ 2019-06-13 16:34
月半榨菜
阅读(73)
评论(0)
推荐(0)
摘要:
1. 自己的写法, 不稳定, O(n2) 2. 冒牌排序, 稳定 ,O(n2) 设置标记 3. 简单选择排序 ,不稳定 51,52,1->1,52,51 , O(n2) 该方法只是选择排序只有在确定了最小数的前提下才进行交换,大大减少了交换的次数。 4. 插入排序 稳定 O(n2) 折半插入排序,使 阅读全文
posted @ 2019-06-13 16:33
月半榨菜
阅读(161)
评论(0)
推荐(0)
浙公网安备 33010602011771号