摘要: 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... 阅读全文
posted @ 2015-06-13 23:10 jianchao-li 阅读(483) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2015-06-13 22:36 jianchao-li 阅读(333) 评论(0) 推荐(0) 编辑
摘要: 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, ... 阅读全文
posted @ 2015-06-13 15:29 jianchao-li 阅读(322) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2015-06-13 14:41 jianchao-li 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2015-06-13 14:19 jianchao-li 阅读(201) 评论(0) 推荐(0) 编辑