摘要:
Given an unsorted array provide two indices n1 and n2 such that if we only sort the elements between n1 and n2,then the whole array will become sorted.n1-n2 should be as minimum as possible.http://www.careercup.com/question?id=4345015参考上面一位大神的解答,非常精彩,不过理解起来有点费力。Let A be the array and T = 0.While A[T 阅读全文
摘要:
Find kth number in a BST递归实现,按照左根右的顺序来实现 1 #include <iostream> 2 using namespace std; 3 4 struct Node 5 { 6 Node *left; 7 Node *right; 8 int val; 9 Node():left(NULL), right(NULL){}10 };11 12 Node *findKthElement(Node *node, int &K)13 {14 if (node == NULL)15 return NULL;1... 阅读全文