Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Stack Problem #2

Open
ndrohith09 opened this issue Oct 16, 2022 · 3 comments
Open

Stack Problem #2

ndrohith09 opened this issue Oct 16, 2022 · 3 comments
Assignees
Labels
easy question Further information is requested

Comments

@ndrohith09
Copy link
Member

ndrohith09 commented Oct 16, 2022

In computer science, a stack or LIFO (last in, first out) is an abstract data type that serves as a collection of elements, with two principal operations: push, which adds an element to the collection, and pop, which removes the last element that was added.(Wikipedia)

A string containing only parentheses is balanced if the following is true: 1. if it is an empty string 2. if A and B are correct, AB is correct, 3. if A is correct, (A) and {A} and [A] are also correct.

Examples of some correctly balanced strings are: "{}()", "[{()}]", "({()})"

Examples of some unbalanced strings are: "{}(", "({)}", "[[", "}{" etc.

Given a string, determine if it is balanced or not.

Input Format

There will be multiple lines in the input file, each having a single non-empty string. You should read input till end-of-file.

Output Format

For each case, print 'true' if the string is balanced, 'false' otherwise.

Sample Input

{}()
({()})
{}(
[]

Sample Output

true
true
false
true
@ndrohith09 ndrohith09 added the question Further information is requested label Oct 16, 2022
@Shiva4584
Copy link
Contributor

Shiva4584 commented Oct 18, 2022

i would like to solve this in c++ @ndrohith09

@ndrohith09
Copy link
Member Author

Yes . I have assigned you. Solve it and raise a PR

@IndexPosition
Copy link
Contributor

I would like to solve this in Python.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
easy question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants