Skip to content

Commit 2e7fac0

Browse files
Update redundant_braces.cpp
1 parent 872353b commit 2e7fac0

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Data Structures/Stacks/redundant_braces.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1-
// Given a string A denoting an expression. It contains the following operators ’+’, ‘-‘, ‘*’, ‘/’.
1+
// Given a string A of length n denoting an expression. It contains the following operators ’+’, ‘-‘, ‘*’, ‘/’.
22
// Check whether A has redundant braces or not.
33

4+
// Input 1:
5+
// A = "((a + b))"
6+
// Output 1:
7+
// 1
8+
// Explanation 1:
9+
// ((a + b)) has redundant braces so answer will be 1.
10+
11+
// Input 2:
12+
// A = "(a + (a + b))"
13+
// Output 2:
14+
// 0
15+
// Explanation 2:
16+
// (a + (a + b)) doesn't have have any redundant braces so answer will be 0.
17+
18+
// Time complexity: O(n)
19+
420
#include <bits/stdc++.h>
521
using namespace std;
622

0 commit comments

Comments
 (0)