SortSort1 SortSelect sort is the simplest sorting alogrithms.1.1 IDEA1.find the smallest element in the rest of array2.exchange the element with with ...
分类:
其他好文 时间:
2015-10-05 22:06:30
阅读次数:
284
Flip over your mind: in rotated subarray case, we can simply cut the continuous smallest subarray.class Solution {public: /** * @param A an int...
分类:
其他好文 时间:
2015-10-02 01:26:38
阅读次数:
248
http://www.codewars.com/kata/smallest-unused-idDescription:Hey awesome programmer!You've got much data to manage and of course you use zero-based and ...
分类:
其他好文 时间:
2015-09-27 21:34:40
阅读次数:
306
解题思路:直接修改中序遍历函数即可,JAVA实现如下:int res = 0; int k = 0; public int kthSmallest(TreeNode root, int k) { this.k = k; inorderTraversal(root); return res; }...
分类:
编程语言 时间:
2015-09-22 18:50:13
阅读次数:
130
1.Drill hole size is equal or larger than smallest pad size. Pad will be drilled away 原因:钻孔直径太大,直接把pad给覆盖了; 措施:将parameter栏下的slot size和slot size的值改...
分类:
其他好文 时间:
2015-09-19 10:55:07
阅读次数:
416
Given a binary search tree, write a function kthSmallest to find the
kth smallest element in it.
Note:
You may assume k is always valid, 1 ≤ k ≤ BST's total elements.
Follow up:
What if the BST ...
分类:
其他好文 时间:
2015-09-18 13:56:58
阅读次数:
178
Kth Smallest Element in a BSTGiven a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is alw...
分类:
其他好文 时间:
2015-09-16 12:30:01
阅读次数:
143
Thinking about it: 我的思路跟sliding window有点类似。假设已经确定了一个区间[l, r],序列中从 l 到 r 恰好包含了[1, K]的各个元素,则从 r 开始继续迭代序列的各个位置,如果发现了1到K的数,则做以下处理: 如果 这个数 刚好是 l 位置上的数,那么.....
分类:
其他好文 时间:
2015-09-11 19:21:51
阅读次数:
154
从包含k个整数的k个数组中各选一个求和,在所有的和中选最小的k个值。思路是多路归并,对于两个长度为k的有序表按一定顺序选两个数字组成和,(B表已经有序)会形成n个有序表A1+B1比较,而现在需要同时合并n个有序表,优先队列(堆)就派上用场了。类似归并排序用i和j维护有序表当前考虑元素,合并的时候,每...
分类:
其他好文 时间:
2015-09-08 00:16:22
阅读次数:
128
Kth Smallest Number in Sorted MatrixFind thekth smallest number in at row and column sorted matrix.Have you met this question in a real interview?YesE...
分类:
其他好文 时间:
2015-09-03 21:33:55
阅读次数:
202