HARMAN Interview Question

In dsa they asked valid parenthesis problem