[Stack] find longest valid parentheses in O(n).