`{"id":"75be81b6-63ca-421c-b7b2-6bead150a79b","name":"Duplicate Brackets","description":"<p>1. You are given a string exp representing an expression. 2. Assume that the expression is balanced i.e. the opening and closing brackets match with each other. 3. But, some of the pair of brackets maybe extra/needless. 4. You are required to print true if you detect extra brackets and false otherwise. e.g.' ((a + b) + (c + d)) -&gt; false (a + b) + ((c + d)) -&gt; true</p>","inputFormat":"<p>A string str</p>","outputFormat":"<p>true or false</p>","constraints":"<p>0 &lt;= str.length &lt;= 100</p>","sampleCode":{"cpp":{"code":"from sys import stdin\r\nexpression = stdin.readline()\r\n#write your code here"},"java":{"code":"#include <bits/stdc++.h>\r\nusing namespace std;\r\nint main(int argc, char **argv)\r\n{ \r\n //write your code\r\n return 0;\r\n}"},"python":{"code":"from sys import stdin\r\nexpression = stdin.readline()\r\n#write your code here\r\n\r\n\r\nprint()"}},"points":10,"difficulty":"easy","sampleInput":"(a + b) + ((c + d))","sampleOutput":"true","questionVideo":"https://www.youtube.com/embed/4eSFaEOa-l0","hints":[],"associated":[{"id":"10ec6896-0229-4172-8e2d-43cd81eee400","name":"What will be the time complexity of the program?(Q- Duplicate Brackets)","slug":"what-will-be-the-time-complexity-of-the-program-q-duplicate-brackets","type":4},{"id":"7a15fed1-4165-43fd-bcf1-741f1d0fb61d","name":"What will be the value of top in an empty stack? (Q- Duplicate Brackets)","slug":"what-will-be-the-value-of-top-in-an-empty-stack-q-duplicate-brackets","type":4},{"id":"d89e99db-bdc2-4acb-9d34-43c783d02b13","name":"In balancing parentheses algorithm, the string is read from?(Q Balanced Bracket)","slug":"in-balancing-parentheses-algorithm-the-string-is-read-from-q-balanced-bracket","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"9847c2b3-e3ad-4b1c-97d1-00206b1be68d","name":"Stacks And Queues For Beginners","slug":"stacks-and-queues-for-beginners","type":0},{"id":"c37ea8da-3749-4bfd-a0db-e453308c0d9b","name":"Duplicate Brackets","slug":"duplicate-brackets","type":1}],"next":{"id":"c689d153-9cc5-4a26-8137-a6001c37bb65","name":"Duplicate Brackets","type":3,"slug":"duplicate-brackets"},"prev":{"id":"addc55c9-5b74-45bf-a11e-0b257643218c","name":"Introduction to Stack","type":0,"slug":"introduction-to-stack"}}}`

Duplicate Brackets

<p>1. You are given a string exp representing an expression. 2. Assume that the expression is balanced i.e. the opening and closing brackets match with each other. 3. But, some of the pair of brackets maybe extra/needless. 4. You are required to print true if you detect extra brackets and false otherwise. e.g.' ((a + b) + (c + d)) -&gt; false (a + b) + ((c + d)) -&gt; true</p>

`{"id":"75be81b6-63ca-421c-b7b2-6bead150a79b","name":"Duplicate Brackets","description":"<p>1. You are given a string exp representing an expression. 2. Assume that the expression is balanced i.e. the opening and closing brackets match with each other. 3. But, some of the pair of brackets maybe extra/needless. 4. You are required to print true if you detect extra brackets and false otherwise. e.g.' ((a + b) + (c + d)) -&gt; false (a + b) + ((c + d)) -&gt; true</p>","inputFormat":"<p>A string str</p>","outputFormat":"<p>true or false</p>","constraints":"<p>0 &lt;= str.length &lt;= 100</p>","sampleCode":{"cpp":{"code":"from sys import stdin\r\nexpression = stdin.readline()\r\n#write your code here"},"java":{"code":"#include <bits/stdc++.h>\r\nusing namespace std;\r\nint main(int argc, char **argv)\r\n{ \r\n //write your code\r\n return 0;\r\n}"},"python":{"code":"from sys import stdin\r\nexpression = stdin.readline()\r\n#write your code here\r\n\r\n\r\nprint()"}},"points":10,"difficulty":"easy","sampleInput":"(a + b) + ((c + d))","sampleOutput":"true","questionVideo":"https://www.youtube.com/embed/4eSFaEOa-l0","hints":[],"associated":[{"id":"10ec6896-0229-4172-8e2d-43cd81eee400","name":"What will be the time complexity of the program?(Q- Duplicate Brackets)","slug":"what-will-be-the-time-complexity-of-the-program-q-duplicate-brackets","type":4},{"id":"7a15fed1-4165-43fd-bcf1-741f1d0fb61d","name":"What will be the value of top in an empty stack? (Q- Duplicate Brackets)","slug":"what-will-be-the-value-of-top-in-an-empty-stack-q-duplicate-brackets","type":4},{"id":"d89e99db-bdc2-4acb-9d34-43c783d02b13","name":"In balancing parentheses algorithm, the string is read from?(Q Balanced Bracket)","slug":"in-balancing-parentheses-algorithm-the-string-is-read-from-q-balanced-bracket","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"9847c2b3-e3ad-4b1c-97d1-00206b1be68d","name":"Stacks And Queues For Beginners","slug":"stacks-and-queues-for-beginners","type":0},{"id":"c37ea8da-3749-4bfd-a0db-e453308c0d9b","name":"Duplicate Brackets","slug":"duplicate-brackets","type":1}],"next":{"id":"c689d153-9cc5-4a26-8137-a6001c37bb65","name":"Duplicate Brackets","type":3,"slug":"duplicate-brackets"},"prev":{"id":"addc55c9-5b74-45bf-a11e-0b257643218c","name":"Introduction to Stack","type":0,"slug":"introduction-to-stack"}}}`

Editor

Duplicate Brackets

easy

1. You are given a string exp representing an expression. 2. Assume that the expression is balanced i.e. the opening and closing brackets match with each other. 3. But, some of the pair of brackets maybe extra/needless. 4. You are required to print true if you detect extra brackets and false otherwise. e.g.' ((a + b) + (c + d)) -> false (a + b) + ((c + d)) -> true

Constraints

0 <= str.length <= 100

A string str

true or false

Example

Sample Input

`.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}(a + b) + ((c + d))`

Sample Output

`.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}true`

Question Video

Discussions

Show Discussion

Related Resources