摘要:
The Longest Common Subsequence (LCS) problem is as follows:Given two sequences s andt, find the length of the longest sequence r, which is a subsequen... 阅读全文
摘要:
The Longest Common Substring (LCS) problem is as follows:Given two strings s and t, find the length of the longest string r, which is a substring of b... 阅读全文
摘要:
This problem is a nice extension of the Valid Parentheses problem.There are several ways to solve it. The first idea is also to use a stack. However, ... 阅读全文
摘要:
Well, there are two ways to add a open or close parenthesis to the current string.If number of(is less thann, you can add(;If number of)is less than n... 阅读全文
摘要:
This is a classic problem of the application of stacks. The idea is, each time we meet a(,{or[, we push it to a stack. If we meet a),}or], we check if... 阅读全文