Search⌘ K
AI Features

Challenge: Reverse Parenthesis

Explore how to calculate the minimum number of reversals required to convert an unbalanced parenthesis string into a balanced one. This lesson teaches you to implement stacks effectively to solve this problem through hands-on practice and problem-solving skills.

Problem

Find how many reversals are needed to convert an unbalanced expression to a balanced one.

Input

A string ...