Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Leetcode 32. Longest Valid Parentheses
Find the length of the longest well-formed (balanced) parentheses substring in a string of '(' and ')', handling nested and adjacent valid segments; this typically requires tracking matching positions or lengths (e.g., via a stack, dynamic programming, or a two-pass counter scan) to do efficiently.
Asked at:
Meta
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early November, 2025
Meta
Mid-level
return the longest valid parentheses substring, after asking clarifying questions the interviewer asked to return either the first longest valid substring or last but it should be deterministic.
Mid October, 2025
Meta
Staff
Given a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring.
Early January, 2025
Meta
Mid-level
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.