Problem Submissions Solution

Redundant Parenthesis

Difficulty: Hard

Acceptance: %

Points: 40.00

Given a valid expression containing only the binary operators '+', '-', '*', '/' and operands, remove all redundant parentheses. Parentheses are considered redundant if removing them does not affect the value of the expression.

Note: The operators '+' and '-' have the same precedence, as do '' and '/'. However, '' and '/' have higher precedence than '+' and '-'.

Your task is to complete the function removeBrackets() which takes the string Exp as input parameters and returns the updated expression.

Topics

Companies

Articles

Examples:

Expected Time Complexity: O(N)

Expected Auxiliary Space: O(N)

Constraints:
  • 1 < Length of Exp < 10^5
  • Exp contains uppercase english letters, '(' , ')', '+', '-', '*' and '/'.
Companies:
Oracle Paypal
Topics:
String Stack
Locked Content
Access Restricted: Please Login to access the code editor and test cases.