Given an even length expression consisting only of { and }, find the min. Number of edits needed to make it a valid balanced expression.
Answers
Answered by
0
Answer:
Input: exp = "}{"
Output: 2
We need to change '}' to '{' and '{' to
'}' so that the expression becomes balanced,
the balanced expression is '{}'
Input: exp = "{{{"
Output: Can't be made balanced using reversals
Input: exp = "{{{{"
Output: 2
Input: exp = "{{{{}}"
Output: 1
Input: exp = "}{{}}{{{"
Output: 3
Hope it helps you....
Similar questions