InterviewBit Academy is now Scaler!
InterviewBit Academy is now Scaler Academy!

Balanced Parantheses!

Problem Description

Given a string A consisting only of '(' and ')'.

You need to find whether parantheses in A is balanced or not ,if it is balanced then return 1 else return 0.

Problem Constraints

1 <= |A| <= 105

Input Format

First argument is an string A.

Output Format

Return 1 if parantheses in string are balanced else return 0.

Example Input

Input 1:

 A = "(()())"

Input 2:

 A = "(()"

Example Output

Output 1:


Output 2:


Example Explanation

Explanation 1:

 Given string is balanced so we return 1

Explanation 2:

 Given string is not balanced so we return 0

NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Balanced Parantheses! on Interview Code Editor
Sign Up
to access hints and editorial solutions for Balanced Parantheses!
Asked In:


Click here to start solving coding interview questions