摘要:
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. 阅读全文
摘要:
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 阅读全文
摘要:
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做,但显然耗时是指数级的。这种类 阅读全文