Skip to content

Commit 5ede788

Browse files
Update redundant_braces.cpp
1 parent 3ee043e commit 5ede788

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

Data Structures/Stacks/redundant_braces.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
// 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-
204
#include <bits/stdc++.h>
215
using namespace std;
226

@@ -67,3 +51,19 @@ int main()
6751
return 0;
6852

6953
}
54+
55+
// Test Cases
56+
// Input 1:
57+
// A = "((a + b))"
58+
// Output 1:
59+
// 1
60+
// Explanation 1:
61+
// ((a + b)) has redundant braces so answer will be 1.
62+
// Input 2:
63+
// A = "(a + (a + b))"
64+
// Output 2:
65+
// 0
66+
// Explanation 2:
67+
// (a + (a + b)) doesn't have have any redundant braces so answer will be 0.
68+
69+
// Time complexity: O(n)

0 commit comments

Comments
 (0)