Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use netbean and java Problem 1 (Array) A bracket sequence is a string that contains only characters' (' and ')'. A correct bracket sequence is

use netbean and java

image text in transcribed

Problem 1 (Array) 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 'l' and '+' between the original characters of the sequence. For example, bracket sequences' () ()' and '(0)' 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 s (5152...S.), where s; denotes the type of its bracket (open or close). It is not mandatory that s is necessarily correct. Your task is to determine the number of i's such that siSit1... SnS1S2...Si-1 is a correct bracket sequence. Input format The single line contains sequence s. Output format Print the number of shifts denoting the correct bracket sequence. Constraints Is 55x105 Sample Input ) 000 Sample Output 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions

Question

Discuss the legal framework of HRM in Canada.

Answered: 1 week ago