← ALL NOTES
String

32. Longest Valid Parentheses

The trick is to track boundaries with a stack of indices, seeded with a -1 sentinel at the bottom meaning "the position just before any valid run." Push the index of every (. On a ), pop — and if the…

Loading…