avinash201199 / avinash201199/DSA-Questions

Bracket Sequences

Open
#483 0 comments 0 reactions 1 assignee Claimed by @syamala27 View on GitHub
Dominant language
C++
Stars
88
Forks
167
PR merge metrics
No merged PRs in 30d

Description

`Problem`
A bracket sequence is a string that contains only characters '(' and ')'.

A correct bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters '1' and '+' between the original characters of the sequence. For example, bracket sequences '()()' and '(())' are correct. The resulting expressions of these sequences are: '(1)+(1)' and '((1+1)+1)'. However, '(', ')(', and '(' are incorrect bracket sequences.

You are given a bracket sequence, where denotes the type of 's bracket (open or close). It is not mandatory that is necessarily correct. Your task is to determine the number of 's such that is a correct bracket sequence.

`Input `
)()()(

`output`
3
`Explanation`
For all i=2,4,6, the shift of string will be ()()(), which is the correct bracket sequence. and the answer is 3

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.