摘要: 之前写过栈的,以为队列的也一样,结果一点都不一样。写了好久啊。因为栈是后进先出,先进去的数字不会影响后面的数字;而队列是先进先出,后进去的会受先进入的数字的影响。比如: (先) 1 9 3 8 4 (后) 这样的序列栈存储 1 9 就可以了,因为9弹出后,自然 1 就是最大的队列... 阅读全文
posted @ 2014-11-21 22:48 匡子语 阅读(457) 评论(0) 推荐(0)
摘要: You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb... 阅读全文
posted @ 2014-11-21 16:26 匡子语 阅读(215) 评论(0) 推荐(0)
摘要: Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a... 阅读全文
posted @ 2014-11-21 15:58 匡子语 阅读(238) 评论(0) 推荐(0)