↓Skip to main content

Bracket-Sequences

LeetCode 32: Longest Valid Parentheses
·3 mins
LeetCode Hard String Dynamic-Programming Stack Bracket-Sequences
LeetCode 32 note: a stack of indices whose bottom is the position just before the current valid run; the length is i - stack[-1]
LeetCode 2267: Check if There Is a Valid Parentheses String Path
·3 mins
LeetCode Hard Dynamic-Programming Grid-Dp Matrix Bracket-Sequences
LeetCode 2267 note: the state is (r, c, open balance); the balance can be neither negative nor more than the remaining steps; search the states with BFS / DP and succeed at the end with balance 0
LeetCode 1021: Remove Outermost Parentheses
·1 min
LeetCode Easy String Stack Bracket-Sequences
LeetCode 1021 note: track depth instead of a stack; the ‘(’ raising depth from 0 to 1 and the ‘)’ lowering it from 1 to 0 are outermost, everything else stays