Question: . Problem 1 (Array) A bracket sequence is a string that contains only characters' (' and ')'. A correct bracket sequence is a bracket sequence

. 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 '(()' 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 (S1$2...sa), 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 sisitl... SnS152... 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 13 155x105 Sample Input > (0) Sample Output 3 Write your code in Java
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
