2015年10月23日

Implement Queue using Stacks

摘要: 1 class Queue { 2 stack input,output; 3 public: 4 // Push element x to the back of queue. 5 void push(int x) { 6 input.push(x); 7... 阅读全文

posted @ 2015-10-23 10:42 RenewDo 阅读(99) 评论(0) 推荐(0) 编辑

Longest Valid Parentheses

摘要: 将所有合法的括号即一对()都消除,用桟保存其中不合法的括号即单个(或)在字符串中的下标。那么每两个不合法之间的下标之差减1就是中间的合法串长度,依次从后向前比较,选出最大的字符串。 1 class Solution { 2 public: 3 int longestValidParenthe... 阅读全文

posted @ 2015-10-23 09:38 RenewDo 阅读(138) 评论(0) 推荐(0) 编辑

导航