摘要: Sort an input string according to the given order string. There might be characters in input string that are not present in the order string and vice-versa. The characters of input string that are not present in the order string should come at the end of the output string in any order. Write code... 阅读全文
posted @ 2012-11-04 23:34 chkkch 阅读(376) 评论(0) 推荐(0) 编辑
摘要: 1. A2. Ctrl+A3. Ctrl+C4. Ctrl+VIf you can only press the keyboard for N times (with the above four keys), please write a program to produce maximum numbers of A. If possible, please also print out the sequence of keys.So the input parameter is N (No. of keys that you can press), the output is M (No. 阅读全文
posted @ 2012-11-04 22:17 chkkch 阅读(447) 评论(1) 推荐(0) 编辑
摘要: Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.http://www.careercup.com/question?id=7263132给出了很精彩的解答。主要的思想是维护一个min_queue,保存当前队列最小值,当新加入一个元素时,min_queue遵照这样的规则从min_queue的尾部开始和新加入元素(key)比较,当min_queue.back() > key时,弹出back(),直到back()<= key,或者min_q 阅读全文
posted @ 2012-11-04 20:06 chkkch 阅读(500) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, find out number of ways in which you can select increasing subsequences of length k(k<=n).for eg array is 1 4 6 2 5 & k=3then the answer is :1 4 5, 1 2 5,1 4 6,so ways are 5he first made me to write a recurrence then asked me to memoize that这题可以用dfs做,但显然耗时是指数级的。这种类 阅读全文
posted @ 2012-11-04 12:02 chkkch 阅读(442) 评论(0) 推荐(0) 编辑