Given a string of parentheses, the task is to find the longest consecutive segment that is balanced, in linear time. We find this problem interesting because it involves a combination of techniques: the usual approach for solving segment problems, and a theorem for constructing the inverse of a function -- through which we derive an instance of shift-reduce parsing.
翻译:考虑到括号的字符串,我们的任务是找到在线性时间中平衡的最长的连续段。我们发现这个问题很有意思,因为它涉及多种技术:解决分段问题的通常方法,以及构建函数反面的理论 -- -- 通过这些理论,我们得出了变化-减速分析的例子。